You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
493 B
26 lines
493 B
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
const int N = 22, M = 80;
|
|
|
|
int n, m, K;
|
|
int f[N][M];
|
|
|
|
int main() {
|
|
cin >> n >> m >> K;
|
|
|
|
memset(f, 0x3f, sizeof f);
|
|
f[0][0] = 0;
|
|
|
|
while (K--) {
|
|
int v1, v2, w;
|
|
cin >> v1 >> v2 >> w;
|
|
for (int i = n; i >= 0; i--)
|
|
for (int j = m; j >= 0; j--)
|
|
f[i][j] = min(f[i][j], f[max(0, i - v1)][max(0, j - v2)] + w);
|
|
}
|
|
|
|
cout << f[n][m] << endl;
|
|
|
|
return 0;
|
|
} |