#include <iostream>
using namespace std;
const int C = 1e6+3;
int n, r, w, t, cnt[2*C][2], res;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
while (n--) {
cin >> r >> w >> t;
cnt[C+w-t][r-1]++;
}
for (int i=0; i<2*C; i++) res += min(cnt[i][0], cnt[i][1]);
cout << res << "\n";
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include <iostream> using namespace std; const int C = 1e6+3; int n, r, w, t, cnt[2*C][2], res; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; while (n--) { cin >> r >> w >> t; cnt[C+w-t][r-1]++; } for (int i=0; i<2*C; i++) res += min(cnt[i][0], cnt[i][1]); cout << res << "\n"; return 0; } |
English