-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1085.cpp
More file actions
42 lines (36 loc) · 916 Bytes
/
1085.cpp
File metadata and controls
42 lines (36 loc) · 916 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
41
42
/*************************************************************************
> File Name: 1085.cpp
> Author: dulun
> Mail: [email protected]
> Created Time: 2016年03月02日 星期三 17时35分34秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;
int dp[50008] = {0};
int count = 0;
int w[50086];
int p[50086];
int c[50086];
int main()
{
int n, W;
scanf("%d%d", &n, &W);
int count = 0;
for(int i = 1; i <= n; i++)
{
count++;
scanf("%d%d%d", &w[count], &p[count], &c[count]);
}
for(int i = 1; i <= count; i++)
{
for(int k=c[i]; k>0; k--)
for(int j = W; j >= w[i]; j--)
{
dp[j] = max(dp[j], dp[j-w[i]]+p[i]);
//printf("dp[%d] = %d \n", j, dp[j]);
}
}
cout<<dp[W];
}