- 采药
- 2009-06-19 17:22:52 @
├ 测试数据 04:运行时错误...| 错误号: 128 |
这是什么意思?(p1104中产生的情况)
下面是我的程序,希望大家指下错,谢谢!!
var t,l,m,i,j,k,max:longint;
a,b:array[1..2000000,1..2] of longint;
begin
readln(t,m);
for i:=1 to m do
readln(a,a);
b[1,1]:=0;
b[1,2]:=0;
l:=1;k:=1;
for i:=1 to m do
begin
for j:=l downto 1 do
if a+b[j,1]max then max:=b;
writeln(max);
end.
2 条评论
-
宋思齐 LV 7 @ 2016-03-01 19:32:07
var
m,n,x,i,j:longint;
f,w,c:array[0..10000] of longint;
function max(a,b:longint):longint;
begin
if a>b then exit(a) else exit(b);
end;
begin
readln(m,n);
for i:=1 to n do readln(w[i],c[i]);
f[0]:=0;
for i:=1 to n do for j:=m downto w[i] do f[j]:=max(f[j],f[j-w[i]]+c[i]); //动态规划过程
writeln(f[m]);
end. -
2016-03-01 19:32:01@
// input code here
- 1