Pagini recente » Cod sursa (job #36864) | Cod sursa (job #1787848) | Cod sursa (job #1645354) | Cod sursa (job #1599856) | Cod sursa (job #121668)
Cod sursa(job #121668)
program operatii;
var f,g:text;
v:array[1..100000] 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;
for i:=1 to max do if v[i]=-1 then inc(p);
close(f);
assign(g,'operatii.out');
rewrite(g);
writeln(g,p);
close(g);
end.