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;
#define MAXN 110
#define MAXM 2010
long long n;
long long s;
long long v[MAXN];
long long w[MAXN];
long long k[MAXN];
long long dp[MAXN][MAXM];
int main()
{
ios_base::sync_with_stdio(false);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>s>>n;
for (long long i=1;i<=n;i++) cin>>v[i]>>w[i]>>k[i];
for (long long i=1;i<=n;i++)
{
for (long long ii=1;ii<=s;ii++)
{
dp[i][ii]=dp[i-1][ii];
for (long long iii=1;iii<=k[i];iii++)
{
if (ii>=iii*w[i]) dp[i][ii]=max(dp[i][ii],dp[i-1][ii-iii*w[i]]+iii*v[i]);
else break;
}
}
}
long long maks=0;
for (long long i=1;i<=s;i++) maks=max(maks,dp[n][i]);
cout<<maks<<endl;
}
# | 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... |