#include <bits/stdc++.h> using namespace std; unordered_map < int, int > mapa[2]; set < int > secik; int main () { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i=0; i<n; i++) { int a, b, c; cin >> a >> b >> c; mapa[a-1][b-c]++; secik.insert(b-c); } int ans = 0; for (auto it: secik) { ans += min (mapa[0][it], mapa[1][it]); } cout << ans; }
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 > mapa[2]; set < int > secik; int main () { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i=0; i<n; i++) { int a, b, c; cin >> a >> b >> c; mapa[a-1][b-c]++; secik.insert(b-c); } int ans = 0; for (auto it: secik) { ans += min (mapa[0][it], mapa[1][it]); } cout << ans; } |