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
45
46
#include<bits/stdc++.h>
#define MAXN 1000*1000+1
using namespace std; 
  
int n,r,w,t;

vector<int> v1,v2;
set<int> valid1,valid2;
int main() 
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    
	
	cin>>n;
    for(int i = 0;i<n;i++)
    	{
    		cin>>r>>w>>t;
    		if(r == 1)
    		{
				valid1.insert(w-t);
    			v1.push_back(w-t);
    		}
			if(r == 2)
			{
    			v2.push_back(w-t);
    			valid2.insert(w-t);
			}
		}
	int odp = v1.size(),tmp = v2.size();
	
	for(auto i : v2)
	{
		if(valid1.count(i) == 0)
			odp++;
	}
	for(auto i : v1)
	{
		if(valid2.count(i) == 0)
			tmp++;
	}
	
	cout<<n-max(tmp,odp)<<endl;
	
    return 0; 
}