hdu5240 Exam
来源:互联网 发布:flash插件 mac 编辑:程序博客网 时间:2024/05/20 18:44
Exam
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 756 Accepted Submission(s): 384
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 leastri 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), wherex 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
Source
The 2015 ACM-ICPC China Shanghai Metropolitan Programming Contest
题意:DRD有n们课程,每次输入三个数分别表示该们课需要复习的时间、考试开始的时间、考试执行的时间。
分析:刚一看题就觉得是贪心,立马就写了,然而WA了三次,着实不解哪里有错,然后看到一片博客,我就呵呵了,就是一大水题,然而题意没说清楚;题目并没有说可以多门课程一起复习,然而这么写却是可以过的。我也真是无力吐槽了。
#include <iostream>#include <cstdio>#include <cstring>#include <stack>#include <queue>#include <map>#include <set>#include <vector>#include <cmath>#include <algorithm>using namespace std;const double eps = 1e-6;const double pi = acos(-1.0);const int INF = 0x3f3f3f3f;const int MOD = 1000000007;#define ll long long#define CL(a) memset(a,0,sizeof(a))struct node{ ll r,e,l;}s[100005];ll cmp(node a, node b){ return a.e<b.e;}int main (){ int T,n,ii=1; scanf ("%d",&T); while (T--) { scanf ("%d",&n); bool flag=false; for (int i=0; i<n; i++) { scanf ("%lld%lld%lld",&s[i].r,&s[i].e,&s[i].l); if (s[i].r > s[i].e)//直接判断是否有需要复习时间在考试开始时间之后就行 { flag = true; } } /*sort(s, s+n, cmp);//这是我之前的WA代码 ll sum=0; for (int i=0; i<n; i++) { if (s[i].e<sum+s[i].r || s[i].r>s[i].e) { flag = true; break; } else sum += (s[i].r+s[i].e+s[i].l); }*/ printf ("Case #%d: ",ii++); if (flag) printf ("NO\n"); else printf ("YES\n"); } return 0;}
0 0
- hdu5240 Exam
- HDU5240 Exam
- hdu5240——Exam(贪心)
- hdu5240
- exam
- Exam
- JAVA EXAM
- Pass4Sure exam
- flex exam
- Happy exam
- youdao exam
- EXAM WAS
- CFA Exam
- hdu4473 Exam
- final exam
- Codeforces534A:Exam
- codeforces Exam
- A. Exam
- 删除字符串中多余的空格
- COCI CONTEST #3 29.11.2014 T1 STROJOPIS
- [CTSC2007]挂缀 解题报告
- 为什么选择CocoaPods进行iOS代码的管理
- Caffe之mnist demo的配置和运行
- hdu5240 Exam
- java虚拟机Class格式与指令
- lintcode-最长公共子序列-77
- COCI CONTEST #3 29.11.2014 T2 DOM
- 主动缓和,化干戈为玉帛
- UIApplication 的学习总结
- COCI CONTEST #3 29.11.2014 T3 SILUETA
- Android Studio---ButterKnife
- 处事变通,转动大脑