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;
struct ITEM
{
int value,weight,copy;
};
int main()
{
int s,n;
cin >> s >> n;
ITEM item[n];
for(int i=0;i<n;i++)
cin >> item[i].value >> item[i].weight >> item[i].copy;
long long dp[s+1]={},result=0;
for(int i=0;i<n;i++)
{
while(item[i].copy--)
{
for(int j=s;j>=item[i].weight;j--)
{
dp[j]=max(dp[j],dp[j-item[i].weight]+item[i].value);
result=max(result,dp[j]);
}
}
}
cout << result;
}
# | 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... |