有一点 wronganswer 了。

测试数据 #0: Accepted, time = 46 ms, mem = 3116 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 3112 KiB, score = 10
测试数据 #2: Accepted, time = 15 ms, mem = 3112 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 3112 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 3116 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 3112 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 3112 KiB, score = 10
测试数据 #7: Accepted, time = 125 ms, mem = 3112 KiB, score = 10
测试数据 #8: WrongAnswer, time = 0 ms, mem = 3112 KiB, score = 0
测试数据 #9: Accepted, time = 93 ms, mem = 3116 KiB, score = 10

program lis;
var
a,d:array[0..300000]of longint;
n,k,i,j:longint;
f:text;
function find(i,fi,la:longint):longint;
var l:longint;
begin
if fi+1=la then exit(la);
l:=(fi+la)div 2;
if d[l]=a[i] then exit(0);
if d[l]<a[i] then exit(find(i,l,la))
else exit(find(i,fi,l));
end;
begin
assign(f,'input8.in');
reset(f);
readln(f,n,k);
for i:=1 to n do read(f,d[i]);
close(f);
j:=0;
for i:=1 to k-1 do
if d[i]<d[k] then
begin inc(j);a[j]:=d[i];end;
inc(j);
a[j]:=d[k];
for i:=k+1 to n do
if d[i]>d[k] then
begin inc(j);a[j]:=d[i];end;
n:=j;
k:=0;
d[0]:=0;
for i:=1 to n do
begin
if a[i]>d[k] then
begin inc(k);
d[k]:=a[i];
continue;
end;
j:=find(i,0,k);
if (j>0)and(d[j]>a[i]) then d[j]:=a[i];
end;
assign(f,'lis.out');
rewrite(f);
writeln(f,k);
close(f);
end.

0 条评论

目前还没有评论...

信息

ID
1369
难度
7
分类
动态规划 | LIS 点击显示
标签
递交数
3264
已通过
542
通过率
17%
被复制
3
上传者