1 solutions
-
3
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int MAXN = 50 + 1; const int MAXM = 100000 + 1; int n, T; long long f[MAXM]; struct Food { long long a; long long b; long long c; }h[MAXN]; bool cmp(Food x, Food y) { return y.b * x.c < x.b * y.c; } int main() { scanf("%d%d", &T, &n); for(int i=1; i<=n; ++i) scanf("%lld", &h[i].a); for(int i=1; i<=n; ++i) scanf("%lld", &h[i].b); for(int i=1; i<=n; ++i) scanf("%lld", &h[i].c); sort(h + 1, h + n + 1, cmp); for(int i=1; i<=n; ++i) for(int j=T; j>=h[i].c; --j) f[j] = max(f[j], f[j - h[i].c] + h[i].a - j * h[i].b); long long ans = 0; for(int i=1; i<=T; ++i) ans = max(ans, f[i]); printf("%lld\n", ans); }
- 1
Information
- ID
- 1043
- Time
- 1000ms
- Memory
- 125MiB
- Difficulty
- 7
- Tags
- # Submissions
- 24
- Accepted
- 7
- Uploaded By