1 solutions
-
0
#include <iostream> #include <cmath> #define QAQ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) using namespace std; int n,m,t=0,v[1000005],w[1000005],s[1000005],dp[1000005]; int main() { QAQ; cin>>n>>m; for(int i=1;i<=n;i++) { int a,b,c; cin>>a>>b>>c; int sum=0; for(int j=1;sum+j<c;j*=2) { v[++t]=a*j; w[t]=b*j; sum+=j; } v[++t]=a*(c-sum); w[t]=b*(c-sum); } for(int i=1;i<=t;i++) { for(int j=m;j>=v[i];j--) { dp[j]=max(dp[j],dp[j-v[i]]+w[i]); } } cout<<dp[m]; return 0; }
Information
- ID
- 1225
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 8
- Tags
- # Submissions
- 26
- Accepted
- 6
- Uploaded By