Exam

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 1029    Accepted Submission(s): 511

Problem Description
As this term is going to end, DRD needs to prepare for his final exams.



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.
 
Input
First line: an positive integer
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.



 
Output
For each test case: output ''Case #x: ans'' (without quotes), where
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).



 
Sample Input
2
3
3 2 2
5 100 2
7 1000 2
3
3 10 2
5 100 2
7 1000 2
 
Sample Output
Case #1: NO
Case #2: YES
 
Source
 
Recommend
We have carefully selected several similar problems for you:  5551 5550 5549 5548 5547



无脑排序加判断

#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()的更多相关文章

  1. hdu 5240 Exam(贪心)

    Exam Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  2. 🔺 Garbage Remembering Exam UVA - 11637()

    题目大意:给你N个单词,有两种方法随机排列,一种随机排成一行,另一种随机排成一圈,当两个单词之间的距离在两种排列中都严格小于K时,则这两个单词构成无效单词,问无效单词的期望. 解题思路:首先对于一排单 ...

  3. 以下C#程序的输出结果是( )。

    以下程序的输出结果是( ). using System; namespace HoverTreeTikuConsole { class Program { static void Main(strin ...

  4. PHP 位运算(&, |, ^, ~, <<, >>)及 PHP错误级别报告设置(error_reporting) 详解

    位运算符允许对整型数中指定的位进行求值和操作. 位运算符 例子 名称 结果 $a & $b And(按位与) 将把 $a 和 $b 中都为 1 的位设为 1. $a | $b Or(按位或) ...

  5. 页面加载完成后,触发事件——trigger()

    <button id="btn">点击我</button> <div id="test"></div> 如果页面 ...

  6. linux/unix 编程手册 fork()函数

    父进程通过fork()函数创建子进程,将父进程数据段和栈的内容拷贝到子进程中,子进程执行程序execve创建新程序,调用exit函数退出到等待wait(),挂起父进程, 父子进程享用相同的程序文本段. ...

  7. setInterval()与clearInterval()的一个有趣小现象

    今天在使用setInterval()时,发现了一个有意思的事情 代码如下: var box=document.getElementById("box");//获取id为“box”的 ...

  8. HTML DOM对象之createElement()方法

    今天在学习DOM节点操作时,发现了创建DOM节点的createElement()方法的一个有意思的现象. 代码如下: var box=document.getElementById("box ...

  9. join()方法之我见

    JavaScript join() 方法 定义和用法 join() 方法用于把数组中的所有元素放入一个字符串. 元素是通过指定的分隔符进行分隔的. 语法 arrayObject.join(separa ...

  10. 转义字符(\)对JavaScript中JSON.parse的影响概述

    JSON是一个提供了stringify和parse方法的内置对象,前者用于将js对象转化为符合json标准的字符串,后者将符合json标准的字符串转化为js对象,本文为大家介绍下转义字符对JSON.p ...

随机推荐

  1. guice基本使用,guice整合guice-servlet,web scope注解(六)

    guice servlet提供了几个比较有用的web scope,类似与传统servlet 的session,request这些提供的范围等. guice servlet 提供的web scope 如 ...

  2. hdu2282 Chocolate 完美匹配 + 拆点

    题意: N个箱子排成一个圈,所有的箱子里的巧克力的数量加起来不大于N,每次可以把箱子里的巧克力向旁边的箱子转移(两个方向),问要让每个箱子里的巧克力不大于1的最小步数. 分析: 把巧克力大于1的箱子拆 ...

  3. python爬虫:读取PDF

    下面的代码可以实现用python读取PDF,包括读取本地和网络上的PDF. pdfminer下载地址:https://pypi.python.org/packages/source/p/pdfmine ...

  4. 检查点和SCN

    有一家叫甲骨文的粮店,老板很严谨,为了防止仓库的粮食在买入卖出的时候发生问题,他制订一套流程,首先进出仓库的每一旦粮食都要求有一个编号(SCN),而且出入库之前必须先放到一个平台上(buffer ca ...

  5. Java 解决一些ACM中大数问题

    大数中算术运算结果的首选标度 运算 结果的首选标度 加 max(addend.scale(), augend.scale()) 减 max(minuend.scale(), subtrahend.sc ...

  6. java RPC系列之一 rmi

    java RPC系列之一    rmi 一.java RPC简单的汇总 java的RPC得到技术,基本包含以下几个,分别是:RMI(远程方法调用) .Caucho的Hessian 和 Burlap . ...

  7. Ubuntu 终端配置

    安装zsh apt install zsh 设置zsh为默认shell chsh -s /bin/zsh 恢复 bash 使用 chsh -s /bin/bash 安装 Oh My Zsh sh -c ...

  8. 第一章 JavaScript 简介

    1.1   JavaScript 的简史 JavaScript 诞生于1995年 ,后由 欧洲计算机制造商协会( ECMA,European Computer Manufacturers Associ ...

  9. Tab 切换效果

    今天写的两个小效果都是为了测试我写的单参函数,结果还是有点成功的~~此处是不是想发表情包! Tab效果很简单,这里我就不赘述了,直接上代码: html代码: <div class="c ...

  10. [USACO08NOV]奶牛混合起来Mixed Up Cows(状态压缩DP)

    题目描述 Each of Farmer John's N (4 <= N <= 16) cows has a unique serial number S_i (1 <= S_i & ...