#include<cstdio> using namespace std; const int MN=100003; int n, k, ciag[2][MN], r[2]={0, 0}; int main() { int i, suma; scanf("%d %d", &n, &k); k=2; for(i=0; i<n; i++) scanf("%d", &ciag[0][i]); for(i=0; i<n; i++){ scanf("%d", &ciag[1][i]); suma=ciag[0][i]+ciag[1][i]; //printf("suma %d %d %d %d %d\n", ciag[0][i], ciag[1][i], suma, r[0], r[1]); if(suma%2==0) printf("%d ", suma/2); else{ if(r[0]>r[1]){ if(ciag[0][i]<ciag[1][i]) printf("%d ", suma/2); else printf("%d ", suma/2+1); r[1]++; } else{ if(ciag[0][i]<ciag[1][i]) printf("%d ", suma/2+1); else printf("%d ", suma/2); r[0]++; } } } 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 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include<cstdio> using namespace std; const int MN=100003; int n, k, ciag[2][MN], r[2]={0, 0}; int main() { int i, suma; scanf("%d %d", &n, &k); k=2; for(i=0; i<n; i++) scanf("%d", &ciag[0][i]); for(i=0; i<n; i++){ scanf("%d", &ciag[1][i]); suma=ciag[0][i]+ciag[1][i]; //printf("suma %d %d %d %d %d\n", ciag[0][i], ciag[1][i], suma, r[0], r[1]); if(suma%2==0) printf("%d ", suma/2); else{ if(r[0]>r[1]){ if(ciag[0][i]<ciag[1][i]) printf("%d ", suma/2); else printf("%d ", suma/2+1); r[1]++; } else{ if(ciag[0][i]<ciag[1][i]) printf("%d ", suma/2+1); else printf("%d ", suma/2); r[0]++; } } } return 0; } |