讨论 / 大神求解,错了20分
破壁人 2017-01-16 20:44:25
点我顶贴 收藏 删除
var a,b:array[0..21,0..21] of longint;

c:array[0..21,0..1001] of boolean;

d,e,f:array[0..401] of longint;

n,m,k,j,i,s,max:longint;

begin

readln(n,m);

for i:=1 to n*m do read(d[i]);readln;

for i:=1 to m do

begin

for j:=1 to n do read(a[i,j]);

readln;

end;

for i:=1 to m do

begin

for j:=1 to n do read(b[i,j]);

readln;

end;

for i:=1 to n*m do

begin

inc(e[d[i]]);

j:=f[d[i]]+1;k:=j;

repeat

if(c[a[d[i],e[d[i]]],j]=true) then

begin

k:=j+1;

while c[a[d[i],e[d[i]]],k]=true do inc(k);

j:=k;

end else inc(j);

if(j-k+1=b[d[i],e[d[i]]]) then break;

until false;

for s:=k to j do c[a[d[i],e[d[i]]],s]:=true;

f[d[i]]:=j;

end;

for i:=1 to n do

begin

for j:=1000 downto 1 do

if(c[i,j]=true) then break;

if(j>max) then max:=j;

end;

writeln(max);

end.

查看更多回复
提交回复