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
  1. 2
  2. 3
  3. 3 2 2
  4. 5 100 2
  5. 7 1000 2
  6. 3
  7. 3 10 2
  8. 5 100 2
  9. 7 1000 2
 
Sample Output
  1. Case #1: NO
  2. Case #2: YES
 
Source
 
Recommend
We have carefully selected several similar problems for you:  5551 5550 5549 5548 5547



无脑排序加判断

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<algorithm>
  4. using namespace std;
  5. struct node
  6. {
  7. int t,e,l;
  8. }edge[100000];
  9. bool cmp(node s1,node s2)
  10. {
  11. return s1.e<s2.e;
  12. }
  13. int main()
  14. {
  15. int t;
  16. int Case=1;
  17. scanf("%d",&t);
  18. while(t--)
  19. {
  20. int n;
  21. scanf("%d",&n);
  22. for(int i=0;i<n;i++)
  23. scanf("%d%d%d",&edge[i].t,&edge[i].e,&edge[i].l);
  24. sort(edge,edge+n,cmp);
  25. int sum=0;
  26. int flog=0;
  27. for(int i=0;i<n;i++)
  28. {
  29. sum+=edge[i].t;
  30. if(sum>edge[i].e)
  31. {
  32. flog=1;break;
  33. }
  34. sum+=edge[i].l;
  35. }
  36. printf("Case #%d: ",Case++);
  37. if(flog) printf("NO\n");
  38. else printf("YES\n");
  39. }
  40. return 0;
  41. }

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. [转]解决C# WinForm 中 VSHOST.EXE 程序不关闭的问题

    右击“解决方案”--属性-调试栏-启用调试器部分-“启用Visual studio宿主进程”不勾选

  2. 判断输入的值是否为Double

    using System; using System.Collections.Generic; using System.Text; namespace TDRFactory { public cla ...

  3. 错误信息:getOutputStream() has already been called for this response

    原因(转): getOutputStream()和getWriter()这两个方法不能在一个请求内同时使用, 如果使用forward,这时将要跳转到的页面是要用getWriter()方法获得输出流把页 ...

  4. (转载)android开发常见编程错误总结

    首页 › 安卓开发 › android开发 android开发常见编程错误总结 泡在网上的日子 / 文 发表于2013-09-07 13:07  第771次阅读 android,异常 0 编辑推荐:稀 ...

  5. 移植最新u-boot(裁剪和修改默认参数)

    [参考]韦东山 教学笔记 ================================================== 最简单的bootloader的编写步骤: 1. 初始化硬件:关看门狗.设 ...

  6. MIME类型记录

    Content-Disposition: attachment; filename="filename.xls" 提供下载

  7. es6学习 http://es6.ruanyifeng.com/

    基础学习   http://es6.ruanyifeng.com/  够了 1字符串 字符串的遍历器接口 for (let codePoint of 'foo') { console.log(code ...

  8. Vs2010无法打开文件“Kernel32.lib”、无法打开“libcpmt.lib”"msvcprt.lib"

    1.对于无法打开"Kernel"问题,即使复制lib文件到目录,仍然会出现最后的错误; 原因:WindowsSdk 安装失败! 方法:重装 microsoft SDK6.0 ,再在 ...

  9. 使用dom4j生成word的方法

    http://blog.csdn.net/zhyh1986/article/details/8727523#t6 http://blog.csdn.net/zuozuofuwaiwai/article ...

  10. 洛谷P1993 小K的农场_差分约束_dfs跑SPFA

    Code: #include<cstdio> #include<queue> using namespace std; const int N=10000+233; const ...