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
#define ft first
#define se second
#define NAME "A"
#define file freopen(NAME".INP","r",stdin); freopen(NAME".OUT","w",stdout);
#define sdf ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define el cout << "\n"
const int MOD = 1e9 + 7, N = 1e5 + 5;
int n, S, v[N], w[N], k[N], dp[N];
int32_t main(){
sdf
cin >> S >> n;
for(int i = 1;i <= n;++i){
cin >> v[i] >> w[i] >> k[i];
}
for(int i = 1;i <= n;++i){
for(int s = S; s >= w[i];--s){
int tmp = min(s / w[i], k[i]);
dp[s] = max(dp[s], dp[s-tmp*w[i]] + v[i]*tmp);
}
}
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... |