记录编号 |
14792 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[BYVoid S3] 阿鲁高的远航 |
最终得分 |
100 |
用户昵称 |
rottenwood |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.491 s |
提交时间 |
2009-11-04 18:51:51 |
内存使用 |
3.19 MiB |
显示代码纯文本
program caonima;
const
maxnum=10000000;
type
shuzu=array[1..1000] of longint;
var
e,c:shuzu;
ans,f:array[0..2001,0..200] of longint;
i,j,k,m,n,v,a,t,w:longint;
procedure dfs(t,rest:longint);
begin
if t>1 then dfs(t-1,rest+e[t]-ans[t,rest]);
writeln(ans[t,rest]);
end;
function min(a,b:longint):longint;
begin
if a>b then min:=b else min:=a;
end;
begin
assign(input,'sail.in');reset(input);
assign(output,'sail.out');rewrite(output);
readln(t,v,a,w);
for i:=1 to t do readln(e[i],c[i]);
for i:=1 to t+1 do
for j:=0 to v do
f[i,j]:=maxnum;
f[1,0]:=0;
for i:=1 to t+1 do
for j:=0 to v do
ans[i,j]:=maxnum;
for i:=1 to t do
for j:=0 to v do
for k:=0 to a do
begin
if (k+j>=e[i])and(k+j<=e[i]+v) then
if f[i,j]+c[i]*k+w*(j+k-e[i])<f[i+1,j+k-e[i]] then
begin
f[i+1,j+k-e[i]]:=f[i,j]+c[i]*k+w*(j+k-e[i]);
ans[i+1,j+k-e[i]]:=k;
end;
end;
for i:=1 to t do
for j:=0 to v do
ans[i,j]:=ans[i+1,j];
writeln(f[t+1,0]);
dfs(t,0);
close(output);
end.