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<iostream>
#include<vector>
using namespace std;
int main(){
int s, n;
cin>>s>>n;
vector<vector<int> > items(n);
for(int i=0; i<n; i++){
int v, w, k;
cin>>v>>w>>k;
items[i]= {v,w,k};
}
vector<int> dp(s+1, 0);
for(int i=0; i<n; i++){
for(int j=items[i][2]; j>0; j--){
for(int k=s; k>=items[i][1]*j; k--){
dp[k]=max(dp[k], dp[k-items[i][1]*j]+items[i][0]*j);
}
}
}
cout<<dp[s]<<endl;
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... |