ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1247. Check a Sequence

Why my program got WA?
Posted by Aleksey S.S. 6 Apr 2003 13:06
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?
Posted by uuuuuuu 6 Apr 2003 15:12
Think about simpler solution -> without array - just O(n) !!
How do you do that???
Posted by Aleksey S.S. 12 Apr 2003 00:28
Re: How do you do that???
Posted by AlexF 2 Feb 2006 10:46
I got AC without any array! )
Re: Why my program got WA?
Posted by Savva'S 7 Oct 2006 23:33
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?
Posted by Savva'S 7 Oct 2006 23:33
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?
Posted by Artem Ladik 13 Aug 2008 14:19
use
 for i:=1 to s do
  for j:=i to s do
   begin
    ....
   end;

{1<=i<=j<=s}