#include <stdio.h>
#include <algorithm>
using namespace std;
int n, r, w, t;
int lines[10*1000*1000][2];
int main() {
// Initialize
for(int i = 0; i < 10*1000*1000; i++) {
lines[i][0] = 0;
lines[i][1] = 0;
}
// Read data
scanf("%d", &n);
for(int i = 0; i < n ; i++) {
scanf("%d %d %d", &r, &w, &t);
lines[(w-t) + 2*1000*1000][r-1]++;
}
// Process data
int ret = 0;
for(int i = 0; i < 10*1000*1000; i++) {
ret += min(lines[i][0], lines[i][1]);
}
// Print result
printf("%d", ret);
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 | #include <stdio.h> #include <algorithm> using namespace std; int n, r, w, t; int lines[10*1000*1000][2]; int main() { // Initialize for(int i = 0; i < 10*1000*1000; i++) { lines[i][0] = 0; lines[i][1] = 0; } // Read data scanf("%d", &n); for(int i = 0; i < n ; i++) { scanf("%d %d %d", &r, &w, &t); lines[(w-t) + 2*1000*1000][r-1]++; } // Process data int ret = 0; for(int i = 0; i < 10*1000*1000; i++) { ret += min(lines[i][0], lines[i][1]); } // Print result printf("%d", ret); return 0; } |
English