jzoj 1286_太空电梯_dp

发布于 2017-07-15  6 次阅读


#include using namespace std; struct arr { int h, l, c; }a[501]; bool f[40001]; int cmp(arr a , arr b) { return a.l < b.l; } int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d%d%d", &a[i].h, &a[i].l, &a[i].c); f[0] = 1; sort(a + 1, a + n + 1, cmp); for (int i = 1; i <= n; i++) for (int k = a[i].l; k >= 0; k--) for (int j = 1; j <= a[i].c && k + a[i].h * j <= a[i].l && f[k] == 1; j++) f[k + a[i].h * j] = 1; for (int i = a[n].l + 1; i >= 0; i--) if (f[i]) { printf("%d\n", i); break; } return 0; } ```]]>


「墨泼三千烟火,许你一世迷离」