Pagini recente » Cod sursa (job #541315) | Cod sursa (job #2432909) | Cod sursa (job #951486) | Cod sursa (job #2773577) | Cod sursa (job #121673)
Cod sursa(job #121673)
program operatii;
var f,g:text;
v:array[1..1000000] of -1..1000000;
p,n,max,i,j,x:longint;
begin
assign(f,'operatii.in');
reset(f);
p:=0;
readln(f,n);
for i:=1 to n do v[i]:=-1;
{max:=0; }
for i:=1 to n do
begin
read(f,x);
{ if x>max then max:=x;}
if x>0 then
for j:=1 to x do
if v[j]=-1 then begin v[j]:=i; inc(p); end
else if v[j]+1=i then v[j]:=i
else begin v[j]:=i; inc(p); end;
end;
close(f);
assign(g,'operatii.out');
rewrite(g);
writeln(g,p);
close(g);
end.