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
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <list>
#include <unordered_map>
#include <string>
#include <map>
#include <queue>
using namespace std;

int main(){
  int n;
  cin >> n;

  map<int, int> counts_r;
  map<int, int> counts_c;
  for(int i = 0; i < n; i++){
    int kind, w, t;
    cin >> kind >> w >> t;
    if(kind == 1){
      counts_r[w - t] ++;
    } else {
      counts_c[w - t] ++;
    }
  }
  int sum = 0;
  for(auto a: counts_r){
    if(counts_c.find(a.first) != counts_c.end()){
      sum += max(a.second, counts_c[a.first]);
    } else {
      sum += a.second;
    }
  }
  for(auto a: counts_c){
    if(counts_r.find(a.first) == counts_r.end()){
      sum += a.second;
    }
  }
  cout << n - sum << endl;
}