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
const int S=2005;
const int N=1e5+5;
int s,n,value[N],weight[N],stock[N],dp[S][N];
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> s >> n;
for(int i=1;i<=n;i++) cin >> value[i] >> weight[i] >> stock[i];
for(int i=1;i<=s;i++){
for(int j=1;j<=n;j++){
dp[i][j]=dp[i-1][j];
for(int k=1;k<=stock[j] && k*weight[j]<=i;k++){
if(k*weight[j]<=i) dp[i][j]=max(dp[i][j],dp[i-k*weight[j]][j-1]+value[j]*k);
}
}
}
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... |