#include <cstdio> #include <algorithm> using namespace std; int A[3][2000001] = {}; 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); A[r][w-t + 999999]++; } int result = 0; for (int i=0; i<2000001; i++) { result += min(A[1][i], A[2][i]); } printf("%d", result); }
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 | #include <cstdio> #include <algorithm> using namespace std; int A[3][2000001] = {}; 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); A[r][w-t + 999999]++; } int result = 0; for (int i=0; i<2000001; i++) { result += min(A[1][i], A[2][i]); } printf("%d", result); } |