#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int n;
int cnt[2][N + N];
int main() {
scanf("%d", &n);
for(int i = 1; i <= n; ++i) {
int r, w, t;
scanf("%d %d %d", &r, &w, &t);
cnt[r - 1][w - t + N]++;
}
int ans = 0;
for(int i = 0; i < N + N; ++i)
ans += min(cnt[0][i], cnt[1][i]);
printf("%d\n", ans);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 7; int n; int cnt[2][N + N]; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) { int r, w, t; scanf("%d %d %d", &r, &w, &t); cnt[r - 1][w - t + N]++; } int ans = 0; for(int i = 0; i < N + N; ++i) ans += min(cnt[0][i], cnt[1][i]); printf("%d\n", ans); } |
English