POJ 2392
来源:互联网 发布:nba林书豪成名战数据 编辑:程序博客网 时间:2024/06/05 06:48
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int judge[40005];//judge[j]用于判断可不可以到达j高度;int use[40005];//use[j]表示当累积到达高度j时用了多少标号为i的石头int n;struct input{ int h,a,c;}stone[405];bool cmp(input x,input y){ return x.a<y.a;}int main(){ int ans; while(scanf("%d",&n)!=EOF) { memset(judge,0,sizeof(judge)); judge[0]=1; for(int i=0;i<n;i++) { scanf("%d%d%d",&stone[i].h,&stone[i].a,&stone[i].c); } sort(stone,stone+n,cmp);//高度上限从小到大排序; ans=0; for(int i=0;i<n;i++) { memset(use,0,sizeof(use)); for(int j=stone[i].h;j<=stone[i].a;j++) { if(judge[j]==0&&j>=stone[i].h&&judge[j-stone[i].h]==1&&use[j-stone[i].h]<stone[i].c)//这个判断可以到达高度j的语句; { judge[j]=1; ans=max(ans,j); use[j]=use[j-stone[i].h]+1; } } } printf("%d\n",ans); } return 0;}
0 0
- poj 2392
- POJ 2392
- poj 2392
- poj 2392
- POJ 2392
- POJ 2392
- POJ 2392 Space Elevator
- poj 2392 Space Elevator
- 【多重背包】POJ 2392
- POJ 2392 Space Elevator
- poj 2392 Space Elevator
- POJ 2392 Space Elevator
- poj 2392 Space Elevator
- POJ-2392-Space Elevator
- poj 2392 DP
- Poj 2392(dp)
- poj 2392 多重背包
- poj 2392 Space Elevator
- 【转】linux shell -- 块注释
- Linux下PCI转串口卡驱动安装方法
- 分辨率常识
- 一些编程上的策略
- ASCII 编码
- POJ 2392
- const char *string() const怎么解释?为什么有两个const
- JS 方法默认参数?
- 动态规划之0-1背包问题
- linux shell ${ }的用法
- 思维方法
- 11-1-(2)-存储班长信息的学生类(private)
- Android APK反编译详解(附图)
- ftok 函数解析