|
|
back to boardWhy i get WA on test 5 ??? #include <stdio.h> int main(){ int mas[100000],i; for(i=0;i<100000;i++) mas[i]=0; int N,k; scanf("%ld",&N); for(i=0;i<N;i++){ scanf("%ld",&k); mas[32768+k]=1; } scanf("%ld",&N); int sol=0,y; for(i=0;i<N;i++){ scanf("%ld",&k); y=10000-k; if((y>=-32768)&&(y<=32767)) if(mas[32768+y]==1){ sol=1; } } if(sol) printf("YES"); else printf("NO");
return 0; } Re: Why i get WA on test 5 ???I get AC. I don't stand why my first solution wrong. This programm get AC. #include <stdio.h> int main(){ int mas[100000],i; for(i=0;i<100000;i++) mas[i]=0; int N,k,y; scanf("%d",&N); for(i=0;i<N;i++){ scanf("%d",&k); y=32768+k; mas[y]=1; } scanf("%d",&N); int sol=0; for(i=0;i<N;i++){ scanf("%d",&k); y=10000-k; if((y>=-32768)&&(y<=32767)){ y=32768+y; if(mas[y]==1){ sol=1; break; } } } if(sol) printf("YES"); else printf("NO");
return 0; } |
|
|