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
#include <iostream>
using namespace std;

int main() 
{
	int n;
	int t1[2000100] = {0}, t2[2000100] = {0};
	int r,w,t;
	int stala = 1000000;
	
	int min = 2000000, max = -2000000;
	int i,j;
	int wynik = 0;
	
	cin >> n;
	while (n-->0)
	{
		cin >> r >> w >> t;
		i = w-t+stala;
		if (r==1) t1[i]++;
		else t2[i]++;; 
		if (min > i) min = i;
		if (max < i) max = i;
	}

//	for (i=min; i<=max; i++) cout << t1[i] << " " << t2[i] << "; " << endl;
	
	for (i=min; i<=max; i++)
	{
		wynik += (t1[i]<t2[i] ? t1[i]:t2[i]);
	}
	
	cout << wynik;
	
	// your code goes here
	return 0;
}