Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {Standal inp, out}
- {ID Zung Nguyen }
- {For the school I've loved}
- var c : array[0..1000000000] of boolean;
- f : text;
- u, max : longint;
- kt : byte;
- a, d : array[0..10000000] of longint; // copy Ngo Huy's words
- N : longint; //10^7 the length of array A
- { oh please do not say it's TLE }
- procedure generate;
- var i:longint;
- begin
- c[1]:=true; u:=1; kt:=1; c[0]:=true;
- for i:=1 to 44720 do
- begin
- if i*u>max then break;
- if kt =1 then
- begin
- c[i*u]:=true;
- kt:=2;
- end else
- begin
- c[i*u+u]:=true;
- kt:=1;
- inc(u);
- end
- end;
- end;
- procedure reada;
- var i:longint;
- begin
- readln(n); max:=-10000001;
- for i:=1 to N do
- begin
- read(a[i]);
- if max<a[i] then max:=a[i];
- end;
- if max<=0 then
- begin
- write(0); halt;
- end;
- end;
- procedure IllfindU;
- var i, j, len:longint;
- begin
- d[0]:=0; a[0]:=0; len:=0;
- for i:=1 to n do if c[a[i]] then
- begin
- d[i]:=0;
- for j:=0 to i-1 do
- if(a[j]<a[i])and (c[a[j]])and(d[i]<d[j]+1) then d[i]:=d[j]+1;
- if len<d[i] then len:=d[i];
- end;
- writeln(len);
- end;
- begin
- reada;
- generate;
- IllfindU;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement