#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
map<int, array<int, 2>> M;
int n;
cin >> n;
while (n--) {
int r, w, t;
cin >> r >> w >> t;
M[w-t][r-1]++;
}
int res=0;
for (auto [a, b]:M) res+=min(b[0], b[1]);
cout << res << endl;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); map<int, array<int, 2>> M; int n; cin >> n; while (n--) { int r, w, t; cin >> r >> w >> t; M[w-t][r-1]++; } int res=0; for (auto [a, b]:M) res+=min(b[0], b[1]); cout << res << endl; return 0; } |
English