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;
const int MOD = 1e9 + 7;
int dp[3<<17];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int s, n;
cin >> s >> n;
vector<int> v(n), w(n), q(n);
for(int i=0; i<n; i++) {
cin >> v[i] >> w[i] >> q[i];
}
for(int j=0; j<n; j++) {
for(int i=s; i>=1; i--) {
if(i >= w[j]) dp[i] = max(dp[i], dp[i-w[j]] + v[j]);
}
}
cout << dp[s] << '\n';
}
# | 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... |