This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int s, n; cin >> s >> n;
vector<int> c(n), w(n), v(n), dp(s+1);
for(int i = 0; i < n; i++){
cin >> v[i] >> w[i] >> c[i];
}
for(int i = 0; i <= n; ++i){
for(int j = s; j >= 0; --j){
for(int l = 1; l <= c[i] && l*w[i] <= j; ++l){
dp[j] = max(dp[j], dp[j - l*w[i]] + l*v[i]);
}
}
}
cout << dp[s];
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... |