1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>
using namespace std;

int n, w, czas, r, res;
int t1[2000007], t2[2000007];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> r >> w >> czas;
        if (r == 1)
            t1[czas - w + 1000000]++;
        else
            t2[czas - w + 1000000]++;
    }
    for (int i = 0; i <= 2000000; i++) {
        res += min(t1[i], t2[i]);
    }
    cout << res;
    return 0;
}