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>
#define ll long long
using namespace std;
ll n,S,i,j,l,res,dp[2005],s[100001],w[100001],k[100001];
int main(){
cin >> S >> n;
for(i=1;i<=n;i++){
cin >> s[i] >> w[i] >> k[i];
}
for(i=1;i<=n;i++){
for(j=1;j<=k[i];j++){
for(l=S;l>=w[i];l--){
dp[l]=max(dp[l],dp[l-w[i]]+s[i]);
}
}
}
for(i=0;i<=S;i++) res=max(res,dp[i]);
cout << res;
}
# | 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... |