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 F first
#define S second
using namespace std;
pair<int,int> p[10005];
int T,n,dp[10005];
int main(){
cin>>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<<=1){
p[num].F=j*v;
p[num].S=j*w;
num++;
s-=j;
}
if(s){
p[num].F=s*v;
p[num].S=s*w;
num++;
}
}
cin>>T;
for(int i=1;i<=num;i++){
for(int j=T;j>=p[i].S;j--){
dp[j]=max(dp[j],dp[j-p[i].S]+p[i].F);
}
}
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... |