Pagini recente » Cod sursa (job #2375020) | Cod sursa (job #1327332) | Cod sursa (job #1112195) | Cod sursa (job #286810) | Cod sursa (job #189120)
Cod sursa(job #189120)
var v:array[1..100000] of integer;
i,n,m,a,b,j,s,o:longint;
begin
assign(input,'aib.in');reset(input);
assign(output,'aib.out');rewrite(output);
read(n,m);
for i:=1 to n do read(v[i]);
for i:=1 to m do begin
read(o);s:=0;
if o=0 then read(a,b);
if o=1 then begin read(a,b);for j:=a to b do s:=s+v[j];writeln(s);end;
if o=2 then begin
read(b);j:=0;
while s<b do begin
inc(j);
s:=s+v[j];
end;
if s=b then writeln(j)
else writeln('-1');
end;
end;
close(input);close(output);
end.