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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<bits/stdc++.h>
using namespace std;

#define ll long long

const int N = 5e5 + 7;

struct xd{
    int r;
    int w;
    int t;
    int z; // zderzenia
};

int n;
xd tab[N];
bool is[N];

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int r, w, t;
        cin >> tab[i].r >> tab[i].w >> tab[i].t;
    }

    int ans = 0;
    bool wypadek = true;

    while(wypadek)
    {
        bool tester = true;
        pair<int, int> maxV = {0, 0};
        for(int i = 0; i < n; i++)
        {
            if(is[i])
                continue;
            int temp = 0;
            for(int j = i + 1; j < n; j++)
            {
                if(is[j])
                    continue;
                if(tab[j].r == tab[i].r)
                    continue;
                if(tab[j].w + tab[i].t == tab[i].w + tab[j].t)
                    temp++;
            }
            tab[i].z = temp;
            maxV = max(maxV, {tab[i].z, i});
        }

        if(maxV.first == 0)
            break;
        ans ++;
        is[maxV.second] = true;
    }



    cout << ans << "\n";
    
}