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
#include<cstdio>
#include<algorithm>

using namespace std;

static int g1[2000001];
static int g2[2000001];

int main(){
    int n;
    scanf("%i", &n);

    for(int i = 0; i < n; ++i){
        int r, w, t;
        scanf("%i%i%i", &r, &w, &t);

        int s = w - t + 1000000;

        if(r == 1){
            g1[s]++;
        }
        else{
            g2[s]++;
        }
    }

    int sum = 0;

    for(int i = 0; i <= 2000000; ++i){
        sum += max(g1[i], g2[i]);
    }

    printf("%i\n", n - sum);

    return 0;
}