#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> struct Collision { int data[3]; }; Collision Collisions[2000002]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int r, w, t; scanf(" %d %d %d", &r, &w, &t); int idx = 1000000 + w - t; Collisions[idx].data[r]++; } int excluded = 0; for (int i = 0; i < 2000001; i++) { if (Collisions[i].data[1] < Collisions[i].data[2]) excluded += Collisions[i].data[1]; else excluded += Collisions[i].data[2]; } printf("%d", excluded); 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 27 28 29 | #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> struct Collision { int data[3]; }; Collision Collisions[2000002]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { int r, w, t; scanf(" %d %d %d", &r, &w, &t); int idx = 1000000 + w - t; Collisions[idx].data[r]++; } int excluded = 0; for (int i = 0; i < 2000001; i++) { if (Collisions[i].data[1] < Collisions[i].data[2]) excluded += Collisions[i].data[1]; else excluded += Collisions[i].data[2]; } printf("%d", excluded); return 0; } |