//Author: Piotr Zielinski #include <bits/stdc++.h> using namespace std; map<int, pair<int, int>> m; int main() { ios::sync_with_stdio(0); cin.tie(nullptr); int n, a, b, c, res = 0; cin >> n; while(n --> 0) { cin >> a >> b >> c; if(a == 1) m[b-c].first++; else m[b-c].second++; } for(auto I : m) { res += min(I.second.first, I.second.second); } cout << res << "\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 | //Author: Piotr Zielinski #include <bits/stdc++.h> using namespace std; map<int, pair<int, int>> m; int main() { ios::sync_with_stdio(0); cin.tie(nullptr); int n, a, b, c, res = 0; cin >> n; while(n --> 0) { cin >> a >> b >> c; if(a == 1) m[b-c].first++; else m[b-c].second++; } for(auto I : m) { res += min(I.second.first, I.second.second); } cout << res << "\n"; return 0; } |