比赛 |
防止颓废的小练习v0.2 |
评测结果 |
AAAAAAAAAA |
题目名称 |
乌龟棋 |
最终得分 |
100 |
用户昵称 |
Ten.X |
运行时间 |
0.308 s |
代码语言 |
Pascal |
内存使用 |
28.06 MiB |
提交时间 |
2016-10-18 14:05:12 |
显示代码纯文本
var i,j,k,h,n,m,x:longint;
a:array[1..350]of longint;
b:array[1..4]of longint;
f:array[-1..50,-1..50,-1..50,-1..50]of longint;
function max(x,y,z,o:longint):longint;
var t:longint;
begin
t:=x;
if t<y then t:=y;
if t<z then t:=z;
if t<o then t:=o;
exit(t);
end;
begin
assign(input,'tortoise.in');reset(input);
assign(output,'tortoise.out');rewrite(output);
fillchar(b,sizeof(b),0);
fillchar(f,sizeof(f),0);
read(n,m);
for i:=1 to n do
read(a[i]);
for i:=1 to m do
begin
read(x);
inc(b[x]);
end;
for i:=0 to b[1] do
for j:=0 to b[2] do
for k:=0 to b[3] do
for h:=0 to b[4] do
f[i,j,k,h]:=a[1+i+2*j+3*k+4*h]+max(f[i-1,j,k,h],f[i,j-1,k,h],f[i,j,k-1,h],f[i,j,k,h-1]);
write(f[b[1],b[2],b[3],b[4]]);
close(input);close(output);
end.