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;
int s,n,v[100010],w[100010],k[100010];
int dp[110][2010];
int main(){
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 j=s;j>=0;j--){
int t = 0;
while(j+t*w[i]<=s && t<=k[i]){
dp[i][j] = max(dp[i-1][j+t*w[i]]+t*v[i],dp[i][j]);
t++;
}
}
}
int ans = 0;
for(int j=0;j<=s;j++){
ans=max(ans,dp[n][j]);
}
cout << ans;
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... |