Code:

#include <bits/stdc++.h>
#define N 4004
#define setIO(s) freopen(s".in","r",stdin)
using namespace std;
int f[N];
struct P
{
int t,f,h;
P(int t=0,int f=0,int h=0):t(t),f(f),h(h){}
}t[N];
bool cmp(P a,P b)
{
return a.t<b.t;
}
int main()
{
int D,n,i,j,mx=0;
// setIO("input");
scanf("%d%d",&D,&n);
for(i=1;i<=n;++i) scanf("%d%d%d",&t[i].t,&t[i].f,&t[i].h);
sort(t+1,t+1+n,cmp);
f[0]=10;
for(i=1;i<=n;++i)
{
for(j=D;j>=0;--j)
{
if(f[j]>=t[i].t)
{
if(j+t[i].h>=D)
{
printf("%d\n",t[i].t);
return 0;
}
f[j+t[i].h]=max(f[j+t[i].h], f[j]);
f[j]+=t[i].f;
mx=max(mx, f[j]);
}
}
}
printf("%d\n",mx);
return 0;
}

  

最新文章

  1. python成长之路【第十六篇】:JavaScript的高级知识---词法分析
  2. char *a 与char a[] 的区别
  3. mysqldump备份与还原mysql数据的实例
  4. support.SerializationFailedException: Failed to deserialize payload.
  5. phpStorm设置显示代码行号
  6. eclipse修改主题配色
  7. [刷题]算法竞赛入门经典(第2版) 5-13/UVa822 - Queue and A
  8. Unicode字符集和编码方式
  9. [译]漫画SELinux概念
  10. Python 三级菜单 增强版
  11. 2、java基础
  12. 配置环境变量及jdk
  13. 【论文笔记】Malware Detection with Deep Neural Network Using Process Behavior
  14. Spock - Document -02 - Spock Primer
  15. Javascript高级编程学习笔记(22)—— 对象继承
  16. 在Mac上 python中使用tesseract OCR (Pytesser) 识别图片中的文字
  17. netbeans 正则替换
  18. oracle数据库无法导出空表的问题解决(开始于oracle11g)
  19. 【Android病毒分析报告】- 手机支付毒王“银行悍匪”的前世今生
  20. 使用C语言操作InfluxDB

热门文章

  1. hdu 1029 求出现次数过半的数
  2. MS SQL 2012表分区
  3. mysql innodb数据库损坏导致无法启动
  4. opencv实现人脸识别(二) 人脸图像采集模块
  5. 「网络流 24 题」最长 k 可重区间集
  6. Java 关于String Pool
  7. eclipse导入maven空项目,eclipse导入时不识别maven项目
  8. luogu4677山区建小学题解--区间DP
  9. java获取类的3种方式
  10. 移植 Linux 内核