|
|
вернуться в форумTimeLimit. Why. type vector=array[1..10000]of integer; var a:vector; function Summa(i,j:integer):longint; var k:longint; S:longint; begin S:=0; for k:=i to j do S:=S+a[k]; Summa:=S; end; var i,j,k:integer; n:integer; q:longint; begin read(n); for i:=1 to n do read(a[i]); read(q); for k:=1 to q do begin read(i,j); if i=j then writeln(Summa(i,j)) else writeln(Summa(1,j)-Summa(1,i-1)); end; end. Why TimeLimite. It's easy. Re: TimeLimit. Why. Your solution is O(N*Q). N=10^4, Q=10^5 => N*Q = 10^9 So it works about one minute on max-test. |
|
|