HDU 4502
直接贪心就好。
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define LL __int64
using namespace std; struct Job{
int s,e,v;
bool operator <(const Job &a)const{
if(e<a.e) return true;
return false;
}
}job[];
int fee[]; int main(){
int T,n,m;
scanf("%d",&T);
while(T--){
scanf("%d%d",&m,&n);
for(int i=;i<n;i++){
scanf("%d%d%d",&job[i].s,&job[i].e,&job[i].v);
}
sort(job,job+n);
while(job[n-].e>m)
n--;
if(n==){
puts("");
continue;
}
memset(fee,,sizeof(fee));
int tmp;
for(int i=;i<n;i++){
fee[i]=job[i].v;
tmp=;
for(int k=;k<i;k++){
if(job[k].e<job[i].s)
tmp=max(tmp,fee[k]);
}
fee[i]+=tmp;
}
tmp=;
for(int i=;i<n;i++)
tmp=max(tmp,fee[i]);
printf("%d\n",tmp);
}
return ;
}
HDU 4502的更多相关文章
- hdu 4502 吉哥系列故事——临时工计划(dp)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4502 思路:一个简单的dp ,比赛时没做出来呢..... d[i]代表 到第i天时的最大值 #includ ...
- hdu 4502吉哥系列故事——临时工计划 (简单DP)
Problem Description 俗话说一分钱难倒英雄汉,高中几年下来,吉哥已经深深明白了这个道理,因此,新年开始存储一年的个人资金已经成了习惯,不过自从大学之后他不好意思再向大人要压岁钱了,只 ...
- hdu 4502 吉哥系列故事——临时工计划_简单dp
题意: 俗话说一分钱难倒英雄汉,高中几年下来,吉哥已经深深明白了这个道理,因此,新年开始存储一年的个人资金已经成了习惯,不过自从大学之后他不好意思再向大人要压岁钱了,只能把唯一的希望放到 ...
- HDU 4502 吉哥系列故事——临时工计划(一维动态规划)
题意:吉哥的假期是1到n天,然后有m个工作可以让吉哥选择做,每个工作都有一个开始 t_s 和结束的时间 t_e ,都用天来表示,然后每个工作必须从第一天做到最后一天, 从头到尾做完之后就可以得到 ...
- hdu 4502 dp
吉哥系列故事——临时工计划 Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tot ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
随机推荐
- Bayesian Regression
Thus we see that there are very close similarities between this Bayesian viewpoint and the conventio ...
- Python入门 来点栗子
查天气(1) http://wthrcdn.etouch.cn/weather_mini?citykey=101280804 http://wthrcdn.etouch.cn/WeatherApi?c ...
- js软键盘
<<!DOCTYPE html><html><head> <title></title></head><body& ...
- [Apple开发者帐户帮助]四、管理密钥(2)获取密钥标识符
创建JSON Web令牌(JWT)以与启用的服务进行通信时,需要密钥标识符. 获取密钥标识符 在“ 证书,标识符和配置文件”中,选择侧栏中“键”下的“全部”. 在右侧,选择私钥. 密钥标识符显示在密钥 ...
- 2015 多校赛 第四场 1009 (hdu 5335)
Problem Description In an n∗m maze, the right-bottom corner is the exit (position (n,m) is the exit) ...
- OpenCV的AdaptiveThreshold函数
摘自于OpenCV Doc2.410,opencv2refman文档. 1.函数原型 adaptiveThreshold //Applies an adaptive threshold to an a ...
- 我的C++笔记(数据的共享与保护)
*数据的共享与保护: * .作用域: * 作用域是一个标识符在程序正文中有效的区域.C++中标识符的作用域有函数原型作用域.局部作用域(块作用域).类作用域和命名空间作用域. * ().函数原型作用域 ...
- react基础篇一
jsx简介 const element = <h1>Hello, world!</h1>; 这种看起来可能有些奇怪的标签语法既不是字符串也不是 HTML. 它被称为 JSX, ...
- win8使用教程
win8如何关机 http://product.pconline.com.cn/itbk/software/win8/1305/3301394.html shutdown.exe -s -t 00 W ...
- Nuxt报错
新增了个文件store.js: //本地存储的工具库 if(!window.localStorage){ alert('你的浏览器不支持localStorage'); } var store ={ s ...