|
|
вернуться в форумWhy my program got WA? var sum,s,n,i,j,k:longint; a:array[1..100]of longint; begin read(s,n); for i:=1 to s do read(a[i]); for j:=1 to s do for i:=1 to j do begin sum:=0; for k:=i to j do sum:=sum+a[k]; if sum>j-i+n+1 then begin write('NO'); exit; end; end; write('Yes'); end. Re: Why my program got WA? Think about simpler solution -> without array - just O(n) !! Re: How do you do that??? Послано AlexF 2 фев 2006 10:46 I got AC without any array! ) Re: Why my program got WA? var sum,s,n,i,j,k:longint; a:array[1..30000]of longint; begin read(s,n); for i:=1 to s do read(a[i]); for j:=1 to s do for i:=1 to j do begin sum:=0; for k:=i to j do sum:=sum+a[k]; if sum>j-i+n+1 then begin write('NO'); exit; end; end; write('YES'); end. Re: Why my program got WA? var sum,s,n,i,j,k:longint; a:array[1..30000]of longint; begin read(s,n); for i:=1 to s do read(a[i]); for j:=1 to s do for i:=1 to j do begin sum:=0; for k:=i to j do sum:=sum+a[k]; if sum>j-i+n+1 then begin write('NO'); exit; end; end; write('YES'); end. Re: Why my program got WA? use for i:=1 to s do for j:=i to s do begin .... end; {1<=i<=j<=s} |
|
|