题目: |
var
n,i,j,t,sum:longint;
a:array[0..50] of longint;
f:array[0..50] of boolean;
begin
readln(n);
for i:= 1 to n do
read(a[i]);
fillchar(f,sizeof (f),true);
for i := 1 to n do
if f[i] then
begin
inc(sum);
t:=a[i] ;
for j:=i to n do
if f[j] and (t=a[j]) then
begin
f[j] := false;
t:=t-1;
if t=0 then
break;
end;
end;
writeln(sum);
end.
【输入】:
8
9 19 11 7 3 2 6 1
输出:5
|