#include
<
iostream
>
using
namespace
std;
int
vn,vm,n;
int
v,w,c;
int
f[
22
][
82
];
int
main()
{
scanf(
"
%d%d%d
"
,
&
vn,
&
vm,
&
n);
memset(f,
0x7F
,
sizeof
(f));
f[
0
][
0
]
=
0
;
for
(
int
i
=
1
;i
<=
n;
++
i){
scanf(
"
%d%d%d
"
,
&
v,
&
w,
&
c);
for
(
int
j
=
vn;j
>=
0
;
--
j)
for
(
int
k
=
vm;k
>=
0
;
--
k)
if
(f[j][k]
<
0xFFFFFFF
){
int
va
=
j
+
v;
if
(va
>
vn) va
=
vn;
int
vb
=
k
+
w;
if
(vb
>
vm) vb
=
vm;
if
(f[va][vb]
>
f[j][k]
+
c)
f[va][vb]
=
f[j][k]
+
c;
}
}
printf(
"
%d\n
"
,f[vn][vm]);
return
0
;
}
posted on 2009-05-01 16:28
xfstart07 阅读(319)
评论(0) 编辑 收藏 引用 所属分类:
代码库