#include <bits/stdc++.h> #define IOSTREAM_BOOST true using namespace std; unordered_map<int, pair<int, int>> m; int n; int a, b, c; int w = 0; int main() { #if IOSTREAM_BOOST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #endif cin >> n; for(int i = 0; i < n; i++){ cin >> a >> b >> c; if(a == 1) m[b - c].first++; else m[b - c].second++; } for(auto p : m) w += min(p.second.first, p.second.second); cout << w << "\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 25 26 27 | #include <bits/stdc++.h> #define IOSTREAM_BOOST true using namespace std; unordered_map<int, pair<int, int>> m; int n; int a, b, c; int w = 0; int main() { #if IOSTREAM_BOOST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #endif cin >> n; for(int i = 0; i < n; i++){ cin >> a >> b >> c; if(a == 1) m[b - c].first++; else m[b - c].second++; } for(auto p : m) w += min(p.second.first, p.second.second); cout << w << "\n"; return 0; } |