比赛 |
20101117 |
评测结果 |
WAWWWAWWWW |
题目名称 |
物品 |
最终得分 |
20 |
用户昵称 |
nick09 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-17 10:03:07 |
显示代码纯文本
- var i,j,k,n,pi,t,y,x,m,tot,tt:longint;
- p1,p2:array[0..1000]of longint;
- w:array[0..6000]of longint;
- s:string;
- r:char;
- procedure init;
- begin
- assign(input,'magica.in');reset(input);
- assign(output,'magica.out');rewrite(output);
- readln(n,pi);j:=0; tot:=0; tt:=0;
- for i:=1 to n do
- begin
- inc(j);
- read(p1[j],r);
- inc(tot,p1[j]);
-
- if r=' ' then begin read(p2[j]);
- if p2[j]-p1[j]-pi>0 then
- begin inc(tt,p2[j]-pi);p2[j]:=p2[j]-pi;end;
- end
-
- end;
- end;
-
- function maxx(a,b:longint):longint;
- begin
- if a>b then maxx:=a
- else maxx:=b;
-
- end;
- function max(a,b,c:longint):longint;
- begin
- if b>a then a:=b;
- if c>a then a:=c;
- max:=a;
-
- end;
-
- procedure go;
- begin
- for i:=1 to n do
- for j:=0 to tot do
- begin
- if j>pi then
- w[j]:=max(w[j],w[j]+p1[i],w[j]+p2[i])
- else
- w[j]:=maxx(w[j],w[j]+p1[i]);
- end;
-
- end;
-
- Begin
- init;
- n:=j;
- go;
- writeln(w[tot]);
- close(input);close(output);
- end.