hdoj--5240--Exam()
Exam
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1029 Accepted Submission(s): 511
DRD has n
exams. They are all hard, but their difficulties are different. DRD will spend at least
ri
hours on the i-th
course before its exam starts, or he will fail it. The
i-th
course's exam will take place ei
hours later from now, and it will last for li
hours. When DRD takes an exam, he must devote himself to this exam and cannot (p)review any courses. Note that DRD can review for discontinuous time.
So he wonder whether he can pass all of his courses.
No two exams will collide.
T≤20
indicating the number of test cases.
There are T cases following. In each case, the first line contains an positive integer
n≤105,
and n
lines follow. In each of these lines, there are 3 integers
ri,ei,li,
where 0≤ri,ei,li≤109.
x
is the number of test cases, and ans
is ''YES'' (without quotes) if DRD can pass all the courses, and otherwise ''NO'' (without quotes).
2
3
3 2 2
5 100 2
7 1000 2
3
3 10 2
5 100 2
7 1000 2
Case #1: NO
Case #2: YES
无脑排序加判断
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct node
{
int t,e,l;
}edge[100000];
bool cmp(node s1,node s2)
{
return s1.e<s2.e;
}
int main()
{
int t;
int Case=1;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d%d%d",&edge[i].t,&edge[i].e,&edge[i].l);
sort(edge,edge+n,cmp);
int sum=0;
int flog=0;
for(int i=0;i<n;i++)
{
sum+=edge[i].t;
if(sum>edge[i].e)
{
flog=1;break;
}
sum+=edge[i].l;
}
printf("Case #%d: ",Case++);
if(flog) printf("NO\n");
else printf("YES\n");
}
return 0;
}
hdoj--5240--Exam()的更多相关文章
- hdu 5240 Exam(贪心)
Exam Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- 🔺 Garbage Remembering Exam UVA - 11637()
题目大意:给你N个单词,有两种方法随机排列,一种随机排成一行,另一种随机排成一圈,当两个单词之间的距离在两种排列中都严格小于K时,则这两个单词构成无效单词,问无效单词的期望. 解题思路:首先对于一排单 ...
- 以下C#程序的输出结果是( )。
以下程序的输出结果是( ). using System; namespace HoverTreeTikuConsole { class Program { static void Main(strin ...
- PHP 位运算(&, |, ^, ~, <<, >>)及 PHP错误级别报告设置(error_reporting) 详解
位运算符允许对整型数中指定的位进行求值和操作. 位运算符 例子 名称 结果 $a & $b And(按位与) 将把 $a 和 $b 中都为 1 的位设为 1. $a | $b Or(按位或) ...
- 页面加载完成后,触发事件——trigger()
<button id="btn">点击我</button> <div id="test"></div> 如果页面 ...
- linux/unix 编程手册 fork()函数
父进程通过fork()函数创建子进程,将父进程数据段和栈的内容拷贝到子进程中,子进程执行程序execve创建新程序,调用exit函数退出到等待wait(),挂起父进程, 父子进程享用相同的程序文本段. ...
- setInterval()与clearInterval()的一个有趣小现象
今天在使用setInterval()时,发现了一个有意思的事情 代码如下: var box=document.getElementById("box");//获取id为“box”的 ...
- HTML DOM对象之createElement()方法
今天在学习DOM节点操作时,发现了创建DOM节点的createElement()方法的一个有意思的现象. 代码如下: var box=document.getElementById("box ...
- join()方法之我见
JavaScript join() 方法 定义和用法 join() 方法用于把数组中的所有元素放入一个字符串. 元素是通过指定的分隔符进行分隔的. 语法 arrayObject.join(separa ...
- 转义字符(\)对JavaScript中JSON.parse的影响概述
JSON是一个提供了stringify和parse方法的内置对象,前者用于将js对象转化为符合json标准的字符串,后者将符合json标准的字符串转化为js对象,本文为大家介绍下转义字符对JSON.p ...
随机推荐
- selenium 最大化浏览器是解决浏览器和驱动不匹配的方法如下
那么要想selenium成功的操作chrome浏览器需要经历如下步骤: 1.下载ChromeDriver驱动包(下载地址: http://chromedriver.storage.googleapis ...
- DevExpress的GridControl拖拽DraopDown后计算HitInfo的RowHandle错误
最近在使用GridControl的拖拽功能时候遇到了一个问题:当GridControl触发DropDrop事件时,计算对应的RowHandle错误.当把鼠标拖拽到GridView一个单元格的靠上面的部 ...
- [lua]异步串行流程*协程
local function param_pack( params, callback ) table.insert(params, callback) return params end local ...
- vue 脚手架 使用步骤
当我知道搭建脚手架得使用命令行的时候.我就崩溃了.所以写一篇记录以后留着自己用也方便大家. 首先要安装一个node 环境, 1.打开cmd 进到你要建项目的目录: E: ...
- aes加密算法的一个问题
百度“delphi aes”出来的结果,千篇一律,都是相互转载,但是没有人发现EldoS, Alexander Ionov于1998-2001写的ElAes.pas代码,存在一个问题. 相同的key和 ...
- caffe学习笔记--跑个SampleCode
Caffe默认情况会安装在CAFFERROOT,就是解压到那个目录,例如: home/username/caffe-master, 所以下面的工作,默认已经切换到了该工作目录.下面的工作主要是,用于测 ...
- 关于XML学习
XML为知识构架存储语言: http://www.w3school.com.cn/xml/xml_tree.asp 语义网:为计算机构建一个系统的概念网络模型是计算机理解概念和机间信息交流的途径:XM ...
- 查看linux机器cpu、内存环境信息
2C2G,4C4G,8C16G,16C32G 这里C指cpu物理核数,G指总内存大小 # 查看物理CPU个数 cat /proc/cpuinfo| grep "physical id&qu ...
- (转)基于MVC4+EasyUI的Web开发框架经验总结(8)--实现Office文档的预览
http://www.cnblogs.com/wuhuacong/p/3871991.html 基于MVC4+EasyUI的Web开发框架经验总结(8)--实现Office文档的预览 在博客园很多文章 ...
- Functor、Applicative 和 Monad(重要)
Functor.Applicative 和 Monad Posted by 雷纯锋Nov 8th, 2015 10:53 am Functor.Applicative 和 Monad 是函数式编程语言 ...