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>
//#include "stdc++.h"
using namespace std;
struct grass{
long long v,w,c;
};
long long dp[10000001];
grass a[100001];
int main(){
int T,m;
cin>>T>>m;
int cnt=0;
for(int i=1;i<=m;i++){
long long v,w,c;
cin>>v>>w>>c;
int t=1;
while(t<=c){
a[++cnt].v=v*t;
a[cnt].w=w*t;
c-=t;
t*=2;
}
if(c>0){
a[++cnt].v=v*c;
a[cnt].w=w*c;
}
}
for(int i=1;i<=cnt;i++){
for(int j=T;j>=a[i].w;j--){
dp[j]=max(dp[j],dp[j-a[i].w]+a[i].v);
}
}
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... |