1 条题解
-
0大金狮 (mengqingyu) LV 10 @ 2024-7-27 14:52:44
奶牛们加油!
#include <iostream> #include <algorithm> using namespace std; struct node { int h, a, c; }s[410]; int n, f[40010]; bool cmp(node x, node y) { return x.a < y.a; } int main() { cin >> n; for (int i = 1; i <= n; i ++) cin >> s[i].h >> s[i].a >> s[i].c; sort(s + 1, s + n + 1, cmp); f[0] = 1; for (int i = 1; i <= n; i ++) for (int j = s[i].a; j >= s[i].h; j --) for (int k = 0; k * s[i].h <= j && k <= s[i].c; k ++) f[j] += f[j - k * s[i].h]; for (int i = s[n].a; i >= 0; i --) if(f[i]) { cout << i << endl; return 0; } }
- 1
信息
- ID
- 2607
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 6
- 标签
- 递交数
- 37
- 已通过
- 12
- 上传者