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 ...
随机推荐
- [Offer收割]编程练习赛32
气泡图 两两判断关系,dfs. #include<stdio.h> #include<string.h> #include<stdlib.h> #include&l ...
- python课程设计笔记(三)turtle绘图库(海龟库)
实例:绘制一条蟒蛇 #turtle:绘图库(海龟库) import turtle turtle.setup(650,350,200,200) turtle.penup() turtle.fd(-250 ...
- less常用方法
最近在开发中使用了less,总结一下less一些常用的方法: 1.可以定义变量 SASS允许使用变量,所有变量以$开头. $blue : #1875e7; div { color : $blue; } ...
- angular4搭建博客(一)
本文长期更新,未经运行,严禁转载. 博客(制作中) http://101.200.58.228/ Github https://github.com/Teloi/TEIndex 框架选择 Angula ...
- LeetCode 42. Trapping Rain Water 【两种解法】(python排序遍历,C++ STL map存索引,时间复杂度O(nlogn))
LeetCode 42. Trapping Rain Water Python解法 解题思路: 本思路需找到最高点左右遍历,时间复杂度O(nlogn),以下为向左遍历的过程. 将每一个点的高度和索引存 ...
- Android高效加载大图
通过BitmapFactory的decode方法设置特定的options缩小图片到指定尺寸 1:通过加载设置了只编码图片边界options的图片,获取原图的尺寸和类型 2:计算图片需要缩小的倍数 3: ...
- RGB_D_开发征程(使用Kinect)
学习历程依此为纲! Kinect学习资料: kinect和openNI开发资料汇总:http://blog.csdn.net/chenli2010/article/details/6887646 原始 ...
- C#学习 第十节
操作符(operator) 1.操作符的概览 从上到下优先级依次减弱: 2.操作符的本质 操作符的本质是函数的简记法: 计算机的操作符不能脱离与它关联的数据类型: 3.操作符的优先级 可以使用括号 4 ...
- Java web课程学习之Servlet
Servlet简介 (1) Servlet本质上就是一个Java类,只不过运行在Servlet容器中 (2) Servlet的功能: ① 创建并返回客户请求的动态HTML页面 ② 创建可嵌入到现有 ...
- 微信小程序:获取地理定位和显示相应的城市名称。
最近在看微信小程序,遇到地理定位显示城市名称的问题.本文就是记录这一过程. 解决方案 ...