#include <algorithm> #include <cstdio> #include <vector> #include <set> using namespace std; long a[2000001][2]; int main() { long n, r, w, t; scanf("%ld", &n); for (long i = 0; i < n; ++i) { scanf("%ld%ld%ld", &r, &w, &t); a[1000000 + w - t][r - 1]++; } long res = 0; for (long i = 0; i < 2000001; ++i) res += min(a[i][0], a[i][1]); printf("%ld", res); 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 | #include <algorithm> #include <cstdio> #include <vector> #include <set> using namespace std; long a[2000001][2]; int main() { long n, r, w, t; scanf("%ld", &n); for (long i = 0; i < n; ++i) { scanf("%ld%ld%ld", &r, &w, &t); a[1000000 + w - t][r - 1]++; } long res = 0; for (long i = 0; i < 2000001; ++i) res += min(a[i][0], a[i][1]); printf("%ld", res); return 0; } |