This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxn = 1e5 + 10;
const int mxs = 2000 + 9;
int n, s, ans;
int pr[mxn], we[mxn], am[mxn];
vector<int> a(mxs, 0), b(mxs, 0);
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin >> s >> n;
for(int i = 1; i <= n; i++)
cin >> pr[i] >> we[i] >> am[i];
for(int i = 1; i <= n; i++) {
for(int j = 0; j <= s; j++) {
for(int k = 0; k <= am[i] && k * we[i] <= j; k++)
b[j] = max(b[j], a[j - k * we[i]] + k * pr[i]);
ans = max(ans, b[j]);
}
swap(a, b);
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |