顶
by 珂珂 @ 2019-10-26 17:33:14
顶
by 珂珂 @ 2019-10-26 17:33:20
顶
by 珂珂 @ 2019-10-26 17:33:26
我也有91的记录,原因是输出时弄错变量了
by 辰星凌 @ 2019-10-26 17:43:30
我印象中这题是跳多了也算跳过 不知道你考虑了吗
by abjfj @ 2019-10-26 17:59:34
```
#include<bits/stdc++.h>
using namespace std;
int d,g,ans,T,F,H;
int dp[5000];
struct node {
int t,f,h;
}ru[5000];
bool cmp(node a,node b){
return a.t<b.t;
}
int main(){
//freopen("in.text","r",stdin);
//freopen("out.text","w",stdout);
scanf("%d%d",&d,&g);
for(int i=1;i<=g;i++){
scanf("%d%d%d",&T,&F,&H);
ru[i].t=T;
ru[i].h=H;
ru[i].f=F;
}
dp[0]=10;
sort(ru+1,ru+g,cmp);
for(int i=1;i<=g;i++)
for(int j=d;j>=0;j--){
if (dp[j]<ru[i].t) continue;
if (j+ru[i].h>=d){
printf("%d",ru[i].t);
return 0;
}
else{
dp[j+ru[i].h]=max(dp[j+ru[i].h],dp[j]);
dp[j]+=ru[i].f;
}
}
printf("%d",dp[0]);
return 0;
}
```
交交这份代码试试
by 墨舞灵纯 @ 2019-10-26 18:06:10
@[可爱的zy珂珂](/space/show?uid=247390)
by 墨舞灵纯 @ 2019-10-26 18:06:14
@[墨舞灵纯](/space/show?uid=87724) 好像没有用。
by 珂珂 @ 2019-10-26 20:58:51
@[abjfj](/space/show?uid=122591) 考虑了
by 珂珂 @ 2019-10-26 20:59:16
@[可爱的zy珂珂](/space/show?uid=247390)
请再次阅读题目。
**等到堆得和井同样高时**
谢谢!
by 喻文州 @ 2019-10-29 16:30:35