|
|
вернуться в форумWhy I got WA ? #include <stdio.h> long n, z, s, poz, min = 10000000; int k; char sir[100009]; //FILE *f; int main () { long i, j; //f = fopen("buffer.in","r"); scanf("%ld %d",&n,&k); if((long)k > n) printf("0\n"); else { scanf("%c",&sir[0]); for(i=1; i<=n; i++) { scanf("%c",&sir[i]); if(sir[i] == '\n') i--; } for(i=1; i<=k; i++) { z--; if(sir[i] == '*') { s += 10; z = k; } else s += sir[i] - '0'; } if(z <= 0 && s < min) { min = s; poz = i-k; } for(; i<=n; i++) { if(sir[i-k] == '*') s -= 10; else s -= sir[i-k] - '0'; z--; if(sir[i] == '*') { s += 10; z = k; } else s += sir[i] - '0'; if(z <= 0 && s < min) { min = s; poz = i-k+1; } } } printf("%ld\n",poz); return 0; } |
|
|