-
Notifications
You must be signed in to change notification settings - Fork 0
/
p1833.cpp
45 lines (45 loc) · 918 Bytes
/
p1833.cpp
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
43
44
45
#include<bits/stdc++.h>
using namespace std;
int ts1,ts2,te1,te2,t,n,dp[1005];
struct node
{
int w;
int v;
int m;
};
node ip[10010];
vector<int> tmp;
int main()
{
scanf("%d:%d",&ts1,&ts2);
scanf("%d:%d",&te1,&te2);
cin>>n;
t=te2-ts2+(te1-ts1)*60;
for(int i=1;i<=n;++i)
{
scanf("%d%d%d",&ip[i].w,&ip[i].v,&ip[i].m);
}
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;++i)
{
if(ip[i].m==0)
{
for(int j=ip[i].w;j<=t;++j)
{
dp[j]=max(dp[j],dp[j-ip[i].w]+ip[i].v);
}
}
else
{
for(int x=1;x<=ip[i].m;++x)
{
for(int j=t;j>=x*ip[i].w;--j)
{
dp[j]=max(dp[j],dp[j-ip[i].w]+ip[i].v);
}
}
}
}
cout<<dp[t];
return 0;
}