|
|
back to boardwhy wrong 3? #include<stdio.h> long n,m; long a[60000],b[60000]; FILE *fin; void init () { long i; scanf ("%ld",&n); for (i=1;i<=n; i++) scanf ("%ld",&a[i]); scanf ("%ld",&m); for (i=1;i<=m; i++) scanf ("%ld",&b[i]); } void work () { long f,i,first,last,x,y; f=1; i=1; while ((f)&&(i<=n)) { first=1; last=m; while ((first<=last)&&(f)) { x=(first+last)/2; if (b[x]+a[i]==10000) f=0; if (b[x]+a[i]<10000 ) last=x-1; else first=x+1; } i++; } if (f==0) printf ("%s\n","YES"); else printf ("%s\n","NO"); } int main () { init (); work (); return 0; } |
|
|