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 mxn=1e5+1,mxs=2e3+1;
int n,s,V[mxn],W[mxn],K[mxn],dp[mxn][mxs];
int main(){
cin.tie(0)->sync_with_stdio(0);
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=1;j<=s;j++){
dp[i][j]=dp[i-1][j];
for(int k=1;k*W[i]<=j&&k<=K[i];k++)
dp[i][j]=max(dp[i][j],dp[i-1][j-k*W[i]]+k*V[i]);
}
}
cout << dp[n][s];
}
# | 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... |