Exam(贪心)
Exam
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1028 Accepted Submission(s): 510
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.
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.
3
3 2 2
5 100 2
7 1000 2
3
3 10 2
5 100 2
7 1000 2
Case #2: YES
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define mem(x,y) memset(x,y,sizeof(x))
using namespace std;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+;
struct Node{
int r,e,l;
};
Node dt[MAXN];
int cmp(Node a,Node b){
return a.e<b.e;
}
int main(){
int T,N,cnt=;
scanf("%d",&T);
while(T--){
scanf("%d",&N);
for(int i=;i<N;i++)
scanf("%d%d%d",&dt[i].r,&dt[i].e,&dt[i].l);
sort(dt,dt+N,cmp);
int flot=,tim=;
for(int i=;i<N;i++){
tim+=dt[i].r;
if(tim>dt[i].e){
flot=;break;
}
tim+=dt[i].l;
}
if(!flot)printf("Case #%d: NO\n",++cnt);
else printf("Case #%d: YES\n",++cnt);
}
return ;
}
Exam(贪心)的更多相关文章
- POJ 3110 Jenny's First Exam (贪心)
题意:告诉你n 个科目的考试日期,在考试当天不能复习,每一个科目的最早复习时间不能早于考试时间的t天,每一天你可以复习完一科,也只能复习一科,求最晚的复习时间!. 析:由于题目给定的时间都在1900 ...
- CF-1093 (2019/02/10)
CF-1093 1093A - Dice Rolling 输出x/2即可 #include<bits/stdc++.h> using namespace std; int main() { ...
- Codeforces Edu Round 56 A-D
A. Dice Rolling 把\(x\)分解为\(a * 6 + b\),其中\(a\)是满6数,\(b\)满足\(1 <= b < 6\),即可... #include <io ...
- ZOJ-3721 Final Exam Arrangement 贪心
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3721 容易的贪心题,排个序.. //STATUS:C++_AC_ ...
- hdu 5240 Exam(贪心)
Exam Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- zoj 3721 Final Exam Arrangement【贪心】
题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3721 来源:http://acm.hust.edu.cn/vjudg ...
- Codeforces Round 56-C. Mishka and the Last Exam(思维+贪心)
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- codeforces 1282C. Petya and Exam (贪心)
链接:https://codeforces.com/contest/1282/problem/C 题意: 有一个人参加考试,考试只有两种题,一种是简单题,每道题耗时固定为a:另一种是困难题,每道题耗 ...
- 【HDOJ6651】Final Exam(贪心)
题意:有n门课,价值之和为m,每门课的价值可能是0到m 一门价值为x的课需要花至少x+1时间准备才能通过 问不管价值如何分配都能通过至少k门课的最小总准备时间 m,n,k<=1e9 思路: #i ...
随机推荐
- JavaScript 深入学习及常用工具方法整理 ---- 01.浮点数
在JavaScript中是不区分整数值和浮点数值的,其中所有的数字均用浮点数值表示.JavaScript采用IEEE 754标准(有兴趣可以浏览网络规范分类下的IEEE 754标准,需要原文件请在留言 ...
- 【Tomcat】使用Eclipse运行Tomcat7源码
1.搭建开发环境 a.下载好tomcat7源码包 b.安装好jdk7,及设置好环境变量 c.安装好ant,及设置好环境变量,用于预编译tocmat源码. d.以上步骤准备好我们就可以开始进入源码的预编 ...
- C++中 指针 与 引用 的区别
四点区别:可否为空,可否修改,使用时是否需要判断,使用场景 非空区别. 引用必须指向某个对象,而指针可以指向空. 可修改区别. 引用总是与初始化时的那个对象绑定,不可变更:指针可以重新赋值,指向另外一 ...
- 解决MySQL 一闪而过的情况
首先进入cmd 切入MySQL的安装目录,然后切入 bin 目录 ,输入mysqld -n t --skip-grant-tables命令. 这个 cmd 窗口先不要关闭, 打开另一个窗口 登陆 ...
- C++之构造函数重载
#include<stdio.h> class Test { private: int i; int j; int k; ...
- 发生了Post错误:错误代码40005,微信返回错误信息:invalid file type
给客户部署 PxxCms, 使用群发功能发送图文的的时候提示: 发生了Post错误:错误代码40005,微信返回错误信息:invalid file type, 没学过php伤不起 ... Google ...
- javamail发送二进制流附件的问题
最近做个邮件发送功能,要内嵌图片并有附件. 需求很奇怪,图片和附件文件是放在ftp服务器上的,查了下javamail的文档. 添加附件方法如下 MimeBodyPart messageBodyPart ...
- [LeetCode]题解(python):099-Recover Binary Search Tree
题目来源: https://leetcode.com/problems/recover-binary-search-tree/ 题意分析: 二叉搜索树中有两个点错了位置,恢复这棵树. 题目思路: 如果 ...
- javascript Node操作
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 生产企业如何部署VMware虚拟化的解决方案
相信生产企业能够清楚的看到,随着生产规模和业务的快速发展,在IT基础设施的投入和使用也不断的增加,但同时也发现没有进行有效整理的硬件效率也就越来 越低,很大程度上浪费了IT资源.所以如何降低成本.提高 ...