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 ll long long
using namespace std;
int n , s;
ll dp[2005];
vector<pair<ll , ll>> a;
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> s >> n;
for(int i = 1 ;i <= n ; i ++){
ll v , w , k;
cin >> v >> w >> k;
ll x = 1;
while(k >= x){
a.push_back({x * v , x * w});
k -= x;
x *= 2;
}
if(k) a.push_back({k * v , k * w});
}
for(pair<ll , ll> i : a){
for(int j = s ; j >= i.second ; j --){
dp[j] = max(dp[j - i.second] + i.first , dp[j]);
}
}
cout << dp[s];
}
# | 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... |