#include<cstdio>
#include<algorithm>
#include<vector>
#define S 2000007
using namespace std;
int V[S][2];
int pref[S];
int pref2[S];
int main(void){
int n,r,w,t;
scanf("%d",&n);
for(int i = 1; i <= n;i++){
scanf("%d %d %d",&r,&w,&t);
V[w-t + 1000001][r-1]++;
}
int odp = 0;
for(int i = 1; i < S;i++){
odp += min(V[i][0],V[i][1]);
}
printf("%d",odp);
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<cstdio> #include<algorithm> #include<vector> #define S 2000007 using namespace std; int V[S][2]; int pref[S]; int pref2[S]; int main(void){ int n,r,w,t; scanf("%d",&n); for(int i = 1; i <= n;i++){ scanf("%d %d %d",&r,&w,&t); V[w-t + 1000001][r-1]++; } int odp = 0; for(int i = 1; i < S;i++){ odp += min(V[i][0],V[i][1]); } printf("%d",odp); return 0; } |
English