hdu 5240 Exam
来源:互联网 发布:人类为何不优化人种 编辑:程序博客网 时间:2024/06/05 15:34
Exam
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1051 Accepted Submission(s): 525
Problem Description
As this term is going to end, DRD needs to prepare for his final exams.
DRD hasn 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.
DRD has
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 integern≤105 , and n lines follow. In each of these lines, there are 3 integers ri,ei,li , where 0≤ri,ei,li≤109 .
There are T cases following. In each case, the first line contains an positive integer
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
233 2 25 100 27 1000 233 10 25 100 27 1000 2
Sample Output
Case #1: NOCase #2: YES#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;struct E{int r,e,l;}e[100010];int cmp(E a,E b){return a.e<b.e;}int main(){int n,c=1,T;scanf("%d",&T);while(T--){scanf("%d",&n);int i,flag=0;for(i=1;i<=n;i++)scanf("%d%d%d",&e[i].r,&e[i].e,&e[i].l);sort(e+1,e+n+1,cmp);for(i=1;i<n;i++) { if(e[i].r>e[i].e) { flag=1; break; } e[i+1].r+=e[i].r+e[i].l; }if(e[n].r>e[n].e) flag=1;if(flag) printf("Case #%d: NO\n",c++);else printf("Case #%d: YES\n",c++);}return 0;}
0 0
- HDU 5240 Exam
- HDU 5240 Exam
- HDU 5240 Exam
- Hdu 5240 Exam【贪心】
- HDU 5240:Exam【排序】
- hdu 5240 Exam
- HDU 5240 Exam(贪心水题)
- hdu 4473 Exam
- hdu 4473 Exam
- hdu 4473 Exam
- hdu 4473 Exam
- hdu 4473 Exam
- [暴力] HDU 4473 Exam
- HDU 5240 Exam (好水的题)
- hdoj 5240 Exam 【模拟】
- 杭电5240Exam
- hdoj--5240--Exam()
- HDOJ 5240 Exam(水)
- 书签地址
- 黑马程序员----Java基础学习之模板设计模式
- Leetcode刷题 sql算法题 178 Rank Scores
- 4,Xcode的调试
- 【ShawnZhang】带你看数据结构——第十二课:图
- hdu 5240 Exam
- WordPress Blog Android客户端源码分析(一)
- 告诉你外语学习的真实方法及误区分析(精编版)
- muduo库阅读(13)——有界的阻塞队列
- form 表单提交的那些事儿
- 从源码角度解析Android事件分发机制
- java中的基本数据类型和引用数据类型
- C++学习路线
- 编程之美-字符串移位问题方法整理