|
|
|
|
讨论 Discussion |
|
|
希望大牛们看一下,只有60分(用了文件不算) |
program lq; const inf='budget.in'; ouf='budget.out'; var v,n,i,j,k,l,c0:longint; c,w:array[0..60,1..3] of longint; b:array[0..60] of byte; f:array[0..60,0..3200] of longint; begin assign(input,inf);reset(input); assign(output,ouf);rewrite(output); readln(v,n); v:=v div 10; fillbyte(b,sizeof(b),1); for i:=1 to n do begin readln(j,k,l); if l=0 then begin inc(c0); c[c0,1]:=j div 10; w[c0,1]:=k; end else begin inc(b[l]); c[l,b[l]]:=j div 10; w[l,b[l]]:=k; end; end; close(input); for i:=1 to c0 do for j:=0 to v do begin f[i,j]:=f[i-1,j]; if ((j>=c[i,1]) and (f[i,j] < (f[i-1,j-c[i,1]]+w[i,1]*c[i,1]))) then f[i,j]:=(f[i-1,j-c[i,1]]+w[i,1]*c[i,1]); if ((j>=c[i,2]+c[i,1]) and (f[i,j] < (f[i-1,j-c[i,1]-c[i,2]]+w[i,1]*c[i,1]+w[i,2]*c[i,2]))) then f[i,j]:=(f[i-1,j-c[i,1]-c[i,2]]+w[i,1]*c[i,1]+w[i,2]*c[i,2]); if ((j>=c[i,3]+c[i,1]) and (f[i,j] < (f[i-1,j-c[i,1]-c[i,3]]+w[i,1]*c[i,1]+w[i,3]*c[i,3]))) then f[i,j]:=(f[i-1,j-c[i,1]-c[i,3]]+w[i,1]*c[i,1]+w[i,3]*c[i,3]); if ((j>=c[i,2]+c[i,1]+c[i,3]) and (f[i,j] < (f[i-1,j-c[i,1]-c[i,2]-c[i,3]]+w[i,1]*c[i,1]+w[i,2]*c[i,2]+w[i,3]*c[i,3]))) then f[i,j]:=(f[i-1,j-c[i,1]-c[i,2]-c[i,3]]+w[i,1]*c[i,1]+w[i,2]*c[i,2]+w[i,3]*c[i,3]); end; writeln(f[c0,v]*10); close(output); end.
( 2009-11-8 20:33:06 )
踮脚眺望^-^... |
|
|
|
|
|
|
|
|
|
Flag |
|
题号 |
P1313 |
类型(?) |
动态规划 |
通过 |
2957人 |
提交 |
9811次 |
通过率 |
30% |
难度 |
2 | |
|
|
|
|
|