|
|
вернуться в форумWrong Answer on Test 11 Послано asddsa 25 апр 2009 15:41 So what's wrong? #include <iostream.h> short a[50000],b[50000],sign[2]={-1,1}; int dist(int a, int b){ int d=a-b; if(d<0)d*=-1; return d; } int main(){ int i,j,k=0,t,n,m; while(cin>>n){ for(i=0;i<n;i++)cin>>a[i]; cin>>m; for(j=0;j<m;j++)cin>>b[j]; for(i=0;i<n;i++){ k=0; j=m-1; while(dist(j,k)!=1){ if(a[i]+b[j]==10000)goto yes; else{ t=j; j+=sign[a[i]+b[j]>10000]*dist(j,k)/2; k=t; } if(a[i]+b[j-1]==10000 || a[i]+b[j]==10000 || a[i]+b[j+1]==10000)goto yes; } } cout<<"NO"; return 0; yes: cout<<"YES"; return 0; } } |
|
|