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
#include <iostream>
#include <map>

using namespace std;


map<int,int> m1, m2;

int main()
{
    int n,r,w,t,b, res = 0;
    cin >> n;

    while(n--) {
        cin >> r >> w >> t;
        if(r == 1) {
            //y = -x + b;
            //-t = -w + b;
            b = w -t;
            m1[b]++;
        } else {
            //y = -x + b;
            //w = t + b;
            b = w -t;
            m2[b]++;
        }

    }
    for(auto i: m1) {
        res+= min(m1[i.first], m2[i.first]);
    }
    cout << res << "\n";
}