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

using namespace std;

int description[2][2000001] = {};

int main()
{

    int n, r, w, t;

    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("\n%d %d %d",&r,&w,&t);
        description[r-1][1000000+w-t]++;
    }


    int result = 0;

    for(int i = 0; i < 2000001; i++) {
        result += min(description[0][i],description[1][i]);
    }

    printf("%d",result);
}