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[10001];
int main(){
int T,m;
cin>>T>>m;
for(int i=1;i<=m;i++){
long long temp1,temp2,temp3;
cin>>temp1>>temp2>>temp3;
a[i]={temp1,temp2,temp3};
}
for(int i=1;i<=m;i++){
for(int j=T;j>=a[i].w;j--){
for(int z=0;z<=a[i].c;z++){
if(j-a[i].w*z<0){
break;
}
dp[j]=max(dp[j],dp[j-a[i].w*z]+a[i].v*z);
}
}
}
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... |