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>
#define ii pair<int, int>
#define fi first
#define se second
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll = long long;
const ll mod=1e9+7;
const int nx=105;
int n, m, w[nx], v[nx], t[nx];
ll ans=0, dp[nx][2005];
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>m>>n;
for(int i = 1; i <= n; i++)
cin>>v[i]>>w[i]>>t[i];
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= m; j++)
{
dp[i][j]=dp[i-1][j];
for(int k = 1; k <= t[i]; k++)
{
if(k*w[i]>j)
break;
dp[i][j]=max(dp[i][j], dp[i-1][j-k*w[i]]+k*v[i]);
}
}
}
cout<<dp[n][m];
}
# | 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... |