比赛 |
20101117 |
评测结果 |
WATTTATTTW |
题目名称 |
物品 |
最终得分 |
20 |
用户昵称 |
maxiem |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-17 10:40:17 |
显示代码纯文本
program magica;
var
data:array [1..1000,1..2] of longint;
p,p1,p2,i,nn,n,ans,m:longint;
procedure search(num,money:longint);
begin
if num=nn+1 then begin
if money>ans then ans:=money;
end
else begin
if (money>=p) and (data[num,2]-p>data[num,1]) then search(num+1,money-p+data[num,2]);
search(num+1,money+data[num,1]);
end;
end;
begin
assign (input,'magica.in');
reset (input);
readln (n,p);m:=0;nn:=0;
for i:=1 to n do begin
read (p1);
if eoln(input) then m:=m+p1 else begin
read (p2);
inc(nn);
data[nn,1]:=p1;
data[nn,2]:=p2;
readln;
end;
end;
close (input);
assign (output,'magica.out');
rewrite (output);
ans:=0;
search(1,m);
writeln (ans);
close (output);
end.