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;
typedef long long int ll;
ll dp[2222];
int main()
{
int s,n;
cin>>s>>n;
vector<pair<ll,ll>>items;
for(int i=0;i<n;i++){
ll v,w,k;
cin>>v>>w>>k;
for(int j=0;j<k;j++)items.push_back({v,w});
}
for(auto x : items){
int v = x.first;
int w = x.second;
for(int i = s;i >= w;i--)dp[i] = max(dp[i],dp[i - w] + v);
}
ll ans = 0;
for(int i=0;i<=s;i++)ans = max(ans,dp[i]);
cout<<ans<<'\n';
}
# | 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... |