[Luogu1156]

f[i]表示高度为i时的存活时间

Code

#include <cstdio>
#include <algorithm>
#define N 110
using namespace std; struct info{
int t,liv,h;
friend bool operator < (info a,info b){
return a.t<b.t;
}
}A[N];
int f[N],dep,n; inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
} int main(){
f[0]=10;
dep=read(),n=read();
for(int i=1;i<=n;++i) A[i].t=read(),A[i].liv=read(),A[i].h=read();
sort(A+1,A+n+1);
for(int i=1;i<=n;++i)
for(int j=dep;j>=0;--j){//注意倒着循环,否则会覆盖上一轮的状态
if(f[j]>=A[i].t){
if(j+A[i].h>=dep){
printf("%d\n",A[i].t);
return 0;
}
f[j+A[i].h]=max(f[j+A[i].h],f[j]);
f[j]+=A[i].liv;
}
}
printf("%d\n",f[0]);
return 0;
}

最新文章

  1. Android ScrollView与ListView的冲突解决办法汇总
  2. MSSQL sp_helptextplus
  3. TimeQuest学习
  4. 更改linux文件夹的默认颜色
  5. magento 小问题解决方案集
  6. windows 下nginx 虚拟主机搭建
  7. VirtualBox网络的Host-Only配置
  8. python下划线的5种含义
  9. C#泛型约束where T : class 解释
  10. LODOP弹出对话框获取保存文件的路径
  11. sql in not in 案例用 exists not exists 代替
  12. Ubuntu18.04的网络配置
  13. rpc框架实现(持续更新)
  14. 递归获取包下的class文件
  15. 转载 IMP时数据库的IO性能监控,并提供IOPS的计算方法
  16. CSS高级布局
  17. postgresql----字符串函数与操作符
  18. OAuth2.0认证和授权以及单点登录
  19. C++中string.find()函数,string.find_first_of函数与string::npos
  20. appium+python自动化58-xpath定位

热门文章

  1. ArcGIS创建要素类
  2. 【Node.js】初识Node.js
  3. C语言问题集
  4. 只为更快、更省、更安全的 Azure CDN
  5. http相关文章目录
  6. 在Sql Server中使用Guid类型的列及设置Guid类型的默认值
  7. 水晶报表分组,统计,求和,sum()函数使用
  8. Microsoft EDP(enterprise database protection)配置策略中的三种Rule template
  9. An internal error occurred during: &quot;Generating JAX-WS Web Services&quot;.Unable to create JAXBContext
  10. MSMQ学习笔记二——创建Message Queue队列