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

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

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