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 ...
随机推荐
- KMP字符匹配算法
上个假期就学了KMP,但是基本不用,所以忘干净了...这个的核心思想就是next数组,next数组学名叫最长相同前缀后缀.还不错的算法,KMP 匹配的过程中比原来的暴力匹配多了一个跳来跳去的next. ...
- Nearest-Neighbor Methods(ESL读书笔记)
Nearest-neighbor methods use those observations in the training set T closest in input space to x f ...
- Android网络连接监听
接收系统网络服务的广播接收者 public class NetStateReceiver extends BroadcastReceiver { private Handler handler; pu ...
- centos7用rpm安装mysql5.7【初始用yum安装发现下载非常慢,就考虑本地用迅雷下载rpm方式安装】
1.下载 4个rpm包 mysql-community-client-5.7.26-1.el7.x86_64.rpmmysql-community-common-5.7.26-1.el7.x86_64 ...
- HDU 1166 线段树模板&树状数组模板
HDU1166 上好的线段树模板&&树状数组模板 自己写的第一棵线段树&第一棵树状数组 莫名的兴奋 线段树: #include <cstdio> using nam ...
- C - Domino piling
Problem description You are given a rectangular board of M × N squares. Also you are given an unlimi ...
- Google的网站性能优化最佳实践
网站性能最佳实践 当描述一个web页面的页面速度,评价的一致性遵循许多不同的规则.这些规则是任何阶段的web开发可以应用的前端最佳实践.这个文档的每个规则都陈述于此,无论你是否运行页面测速工具-- ...
- css下拉菜单写法
网页导航栏的下拉效果,通过div框的显示和隐藏实现. <html> <head> <meta charset="UTF-8"> <titl ...
- VHDL之concurrent之block
1 Simple BLOCK The simple block represents only a way of partitioning the code. It allows concurrent ...
- yar 调用rpc方法
<?php class RpcController extends Yaf_Controller_Abstract { //RPC入口 public function indexAction($ ...