求助54分

P1156 垃圾陷阱

juyaohui?
by Wind_Shear @ 2019-11-01 07:13:23


@[Wind_Shear](/space/show?uid=220889) ???你是……
by SDNetFriend @ 2019-11-04 20:25:15


@[SB_Net_Friend](/space/show?uid=206258) 嘿嘿
by Wind_Shear @ 2019-11-04 21:25:36


我先看一下,明后天回复
by yangwenbin @ 2019-11-07 20:43:10


@[yangwenbin](/user/129390) okok谢谢哈
by SDNetFriend @ 2019-11-07 23:43:54


``` // // P1156 垃圾陷阱.cpp // cpp // // Created by 杨文宾 on 2019/11/8. // Copyright © 2019 杨文宾. All rights reserved. // #include <bits/stdc++.h> using namespace std; struct trash{ int t,h,l; }rubbish[150]; int d,g; int ti[150]; int dp[150]; bool cmp(trash a,trash b){ return a.t<b.t; } int main(){ cin>>d>>g; for(int i=1;i<=g;i++){ cin>>rubbish[i].t>>rubbish[i].l>>rubbish[i].h; } sort(rubbish+1,rubbish+1+g,cmp); dp[0]=10; for(int i=1;i<=g;i++){ for(int j=d;j>=0;j--){ if(dp[j]>=rubbish[i].t){ if(j+rubbish[i].h>=d){ cout<<rubbish[i].t; return 0; } dp[j+rubbish[i].h]=max(dp[j+rubbish[i].h],dp[j]); dp[j]+=rubbish[i].l; } } } cout<<dp[0]; return 0; } ```
by yangwenbin @ 2019-11-08 21:16:57


@[yangwenbin](/user/129390) 谢谢大佬,感激不尽
by SDNetFriend @ 2019-11-10 19:36:01


@[yangwenbin](/user/129390) 谢谢大佬,感激不尽
by SDNetFriend @ 2019-11-10 19:36:12


|