#include <bits/stdc++.h> using namespace std; unordered_map<int,int> M[2]; unordered_set<int> coords; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { int type, x, y; cin >> type >> x >> y; M[type-1][x-y]++; coords.insert(x-y); } int result = 0; for (int x : coords) result += min(M[0][x], M[1][x]); cout << result << "\n"; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <bits/stdc++.h> using namespace std; unordered_map<int,int> M[2]; unordered_set<int> coords; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { int type, x, y; cin >> type >> x >> y; M[type-1][x-y]++; coords.insert(x-y); } int result = 0; for (int x : coords) result += min(M[0][x], M[1][x]); cout << result << "\n"; return 0; } |