比赛 |
NOIP2008集训模拟2 |
评测结果 |
C |
题目名称 |
阿鲁高的远航 |
最终得分 |
0 |
用户昵称 |
Hamster |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-11 11:10:05 |
显示代码纯文本
program sail;
var
fin,fout:text;
t,v,a,w,i,s:integer;
n,b:array[1..100] of integer;
f,fv:array[1..1000] of longint;
procedure init;
begin
assign(fin,'sail.in');
assign(fout,'sail.out');
reset(fin);
rewrite(fout);
readln(f1,t,v,a,w);
for i:=1 to t do
readln(f1,n[i],b[i]);
fillchar(f,sizeof(f),0);
fillchar(fv,sizeof(fv),0);
end;
procedure db;
var
i,j,tt:integer;
begin
for i:=1 to t do
begin
for j:=1 to i-1 do
if a-f[j]>0 then
if b[j]+(i-j)*w<=b[i] then
begin
if a-f[j]>n[i] then
begin
if a-f[j]>v then tt:=v
else tt:=n[i];
f[j]:=f[j]+tt;
fv[i]:=fv[i]+tt*(b[j]+(i-j)*w);
end
else
begin
tt:=f[j];
fv[i]:=fv[i]+tt*(b[j]+(i-j)*w);
f[j]:=a;
end;
n[i]:=n[i]-tt;
end;
if n[i]>0 then
begin
fv[i]:=fv[i]+n[i]*b[i];
f[i]:=n[i];
end;
end;
end;
begin
init;
dp;
for i:=1 to t do s:=s+fv[i];
writeln(fout,s);
for i:=1 to t do writeln(fout,f[i]);
close(fin);
close(fout);
end.