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 ll;
struct Produkt{
ll v,w,k;
};
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
cout << fixed << setprecision(8);
int s,n; cin >> s >> n;
vector<Produkt> p(n);
for(int i = 0;i<n;i++){
Produkt pt;
cin >> pt.v >> pt.w >> pt.k;
for(int j = 0;j<pt.k;j++){
p.push_back(pt);
}
}
vector<ll> dp(s+1,0);
ll ans = 0;
for(int i = 0;i<n;i++){
for(int j = p[i].w;j<=s;j++){
dp[j-p[i].w] = max(dp[j-p[i].w],dp[j] + p[i].v);
ans = max(ans,dp[j-p[i].w]);
}
}
cout << ans;
}
# | 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... |