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 V[10000],W[10000];
int T,n,dp[100005];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>T>>n;
int num=1;
for(int i=1;i<=n;i++){
int v,w,s;
cin>>v>>w>>s;
for(int j=1;j<=s;j++){
V[num]=v;
W[num]=w;
num++;
}
}
/*cout<<"\n";
for(int i=1;i<num;i++){
cout<<W[i]<<' ';
}*/
for(int i=1;i<=num;i++){
for(int j=T;j-W[i]>=0;j--){
dp[j]=max(dp[j],dp[j-W[i]]+V[i]);
}
}
cout<<dp[T];
}
# | 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... |