-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1085_second.cpp
More file actions
40 lines (34 loc) · 892 Bytes
/
Copy path1085_second.cpp
File metadata and controls
40 lines (34 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*************************************************************************
> File Name: 1085_second.cpp
> Author: dulun
> Mail: dulun@xiyoulinux.org
> Created Time: 2016年03月18日 星期五 13时20分34秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define LL long long
using namespace std;
const int N = 50086;
int dp[N];
int main()
{
int n, W;
scanf("%d%d", &n, &W);
int maxx = 0;
for(int i = 1; i <= n; i++)
{
int w, p, c;
cin>>w>>p>>c;
for(int k = 1; k <= c; c-=k, k<<=1)
for(int j = W; j >= w*k; j--)
{
dp[j] = max(dp[j], dp[j-w*k]+p*k);
}
for(int j = W; j>= w*c; j--) dp[j] = max(dp[j], dp[j-w*c]+c*p);
}
cout<<dp[W]<<endl;
return 0;
}