Pagini recente » Cod sursa (job #2145466) | Cod sursa (job #1501374) | Cod sursa (job #1877059) | Cod sursa (job #2321266) | Cod sursa (job #251109)
Cod sursa(job #251109)
var f,g:text;
v,c:array[1..10000] of longint;
n,m,i,j,x,s,y,p:longint;
begin
assign(f,'aib.in');
reset(f);
assign(g,'aib.out');
rewrite(g);
readln(f,n,m);
for i:=1 to n do
begin
read(f,v[i]);
c[i]:=c[i-1]+v[i];
end;
for i:=1 to m do
begin
read(f,p);
if p=2 then
begin
read(f,x);
for j:=1 to n do
if c[j]=x then begin writeln(g,j); break;end;
end
else
begin
read(f,x,y);
if p=1 then
begin
s:=c[y]-c[x-1];
writeln(g,s);
end
else
begin
c[x]:=c[x]+y;
for j:=x to n do
c[j]:=c[j]+y;
v[x]:=v[x]+y
end
end;
end;
close(g);
end.