- 导弹拦截
- 2014-08-19 19:12:59 @
测试数据 #0: WrongAnswer, time = 0 ms, mem = 820 KiB, score = 0
测试数据 #1: WrongAnswer, time = 0 ms, mem = 820 KiB, score = 0
测试数据 #2: TimeLimitExceeded, time = 1015 ms, mem = 820 KiB, score = 0
测试数据 #3: TimeLimitExceeded, time = 1015 ms, mem = 820 KiB, score = 0
测试数据 #4: Accepted, time = 15 ms, mem = 816 KiB, score = 16
测试数据 #5: Accepted, time = 0 ms, mem = 820 KiB, score = 18
2 条评论
-
1312066955 LV 7 @ 2014-08-21 22:01:44
DP
-
2014-08-19 19:16:19@
var
h,l,b:array[0..100]of longint;
i,k,j,n,p,max:longint;
s:string;
procedure get(x:longint);
var i:longint;
begin
if x>n then begin if j>max then max:=j; exit; end;
for i:=x to n do
if (h[i]<b[j])or(j=0) then
begin
j:=j+1;
b[j]:=h[i];
get(x+1);
b[j]:=0;
j:=j-1;
end
else get(x+1);
end;begin
readln(s);j:=1;
for i:=1 to length(s) do
if (s[i]>='0') and(s[i]<='9') then h[j]:=h[j]*10+ord(s[i])-ord('0')
else inc(j);
k:=1;
l[1]:=h[1];
n:=j;
for i:=2 to n do
begin
p:=0;
for j:=1 to k do
if l[j]>h[i] then
if p=0 then p:=j
else if l[j]<l[p] then p:=j;
if p=0 then begin inc(k); l[k]:=h[i]; end
else l[p]:=h[i];
end;
j:=0;
get(1);
write(max);
write(',');
write(k-1);
end.
- 1