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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>
using namespace std;

int zderz[2][2000000];

int main(){
int n,a,b,c,wyn=0;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a>>b>>c;
    if(a==1){
        if((b-c)>=0){
            zderz[0][b-c]++;
        }else{
            zderz[0][(b-c)*-1+1000000]++;
        }
    }else{
        if((b-c)>=0){
            zderz[1][b-c]++;
        }else{
            zderz[1][(b-c)*-1+1000000]++;
        }
    }

}
for(int i=0;i<2000000;i++){
    if(zderz[0][i]>0 and zderz[1][i]>0){
        if(zderz[0][i]>zderz[1][i]){
            wyn=wyn+zderz[1][i];
        }else{
            wyn=wyn+zderz[0][i];
        }
    }
    if(zderz[0][i]<0 and zderz[1][i]<0){
        if(zderz[0][i]>zderz[1][i]){
            wyn=wyn+(zderz[1][i]*-1);
        }else{
            wyn=wyn+(zderz[0][i]*-1);
        }
    }
}
cout<<wyn;
return 0;
}