比赛 |
20101118 |
评测结果 |
AAAWWWWWWW |
题目名称 |
情敌 |
最终得分 |
30 |
用户昵称 |
belong.zmx |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-18 11:11:42 |
显示代码纯文本
program rival(input,output);
var
i,j,k,head:longint;
t1,t2:longint;
n,m,x,y,ans:longint;
w,t:array[1..50]of longint;
w1,p1:array[1..1000]of longint;
tt:array[1..50]of boolean;
f:array[0..101,0..101]of longint;
function max(a,b:longint):longint;
begin
if a>b then max:=a else max:=b;
end;
begin
assign(input,'rival.in');
reset(input);
readln(t1,t2);
readln(n,m);
for i:=1 to n do
begin
readln(w[i],t[i]);
ans:=ans+w[i];
if (t[i]>t1)and(t[i]*2>t2) then
tt[i]:=true;
end;
close(input);
for i:=1 to n do
if tt[i]=false then
begin
inc(head);
w1[head]:=w[i];
p1[head]:=t[i];
end;
for i:=1 to head do
for j:=t1 downto 0 do
for k:=t2 downto 0 do
begin
if j-p1[i]>=0 then
f[j,k]:=max(f[j,k],f[j-p1[i],k]+w1[i]);
if k-2*p1[i]>=0 then
f[j,k]:=max(f[j,k],f[j,k-2*p1[i]]+w1[i]);
end;
assign(output,'rival.out');
rewrite(output);
writeln(ans-f[t1,t2]);
close(output);
end.