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 1330. Intervals

Please help! Why "Wrong Answer"?
Posted by Ivasyuk Roman 28 May 2005 16:17
Please help! Why "Wrong Answer"?
Var n,q,i,j : longint;
    s,e,suma : longint;
    a : array [1..10010] of longint;

Begin
   readln(n);
   for i:=1 to n do
   readln(a[i]);
   readln(q);
   for i:=1 to q do
   Begin
     suma:=0;
     readln(s,e);
     for i:=s to e do suma:=suma+a[i];
     writeln(suma);
   End;
End.
see+++++++++++++
Posted by Виктор Крупко 29 May 2005 02:09
Var n,q,i,j : longint;
s,e,suma : longint;
a : array [1..10010] of longint;

Begin
readln(n);
for i:=1 to n do
readln(a[i]);
readln(q);
for i:=1 to q do
Begin
suma:=0;
readln(s,e);
for j:=s to e do suma:=suma+a[j]; {see i>>j}
writeln(suma);
End;
End.
but be time limit, Search for other way!!!
Re: see+++++++++++++
Posted by Ivasyuk Roman 29 May 2005 13:40
With many thanks for help, for specified mistake. I have got Time Limit, and has remade algorithm and has finally got AC