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 <iostream>
#include <vector>
using namespace std;
int main() {
cin.tie(0); iostream::sync_with_stdio(false);
int s, n; cin >> s >> n;
vector<int> best(s+1);
while (n--) {
int v, w, k; cin >> v >> w >> k;
k = min(k, s / w);
while (k--) {
for (int i = s-w; i >= 0; --i) {
auto& r = best[i+w];
r = max(r, best[i] + v);
}
}
}
cout << best[s] << endl;
}
# | 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... |