贪心。。

#include<iostream>
#include<string.h>
#include<math.h>
#include <stdio.h>
#include <algorithm> using namespace std; struct node
{
int s,t;
int m;
}; node a[]; int cmp(node a,node b)
{
return a.m<b.m;
} int main()
{
int n;
int i,j;
int now;
while(scanf("%d",&n)!=EOF)
{
if(n==)
break;
for(i=;i<n;i++)
{
scanf("%d%d",&a[i].s,&a[i].t);
if((a[i].t-a[i].s)%==)
a[i].m=a[i].s+(a[i].t-a[i].s)/-;
else
a[i].m=a[i].s+(a[i].t-a[i].s)/;
}
sort(a,a+n,cmp);
now=;
int flag=;
int cnt=;
for(i=;i<n;i++)
{
if(now>a[i].m)
{
flag=;
break;
}
else if(now<=a[i].s)
now=a[i].s+(a[i].t-a[i].s)/+;
else if(now>a[i].s)
now=now+(a[i].t-a[i].s)/+;
cnt++;
} if(flag)
printf("NO\n");
else
{
if(cnt==n)
printf("YES\n");
else
printf("NO\n");
}
}
return ;
}

HDU 2491 Priest John's Busiest Day的更多相关文章

  1. HDU 2491 Priest John's Busiest Day(贪心)(2008 Asia Regional Beijing)

    Description John is the only priest in his town. October 26th is the John's busiest day in a year be ...

  2. 图论(2-sat):Priest John's Busiest Day

    Priest John's Busiest Day   Description John is the only priest in his town. September 1st is the Jo ...

  3. POJ 3683 Priest John's Busiest Day / OpenJ_Bailian 3788 Priest John's Busiest Day(2-sat问题)

    POJ 3683 Priest John's Busiest Day / OpenJ_Bailian 3788 Priest John's Busiest Day(2-sat问题) Descripti ...

  4. 【POJ3683】Priest John's Busiest Day

    题目 John is the only priest in his town. September 1st is the John's busiest day in a year because th ...

  5. poj 3686 Priest John's Busiest Day

    http://poj.org/problem?id=3683 2-sat 问题判定,输出一组可行解 http://www.cnblogs.com/TheRoadToTheGold/p/8436948. ...

  6. POJ 3683 Priest John's Busiest Day (2-SAT)

    Priest John's Busiest Day Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6900   Accept ...

  7. POJ 3683 Priest John's Busiest Day(2-SAT+方案输出)

    Priest John's Busiest Day Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10010   Accep ...

  8. Priest John's Busiest Day(POJ 3683)

    原题如下: Priest John's Busiest Day Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 12162   ...

  9. POJ 3683 Priest John's Busiest Day(2-SAT 并输出解)

    Description John is the only priest in his town. September 1st is the John's busiest day in a year b ...

随机推荐

  1. nginx对网站限速

    注意:nginx 1.1.8 之后的版本的语法改为limit_conn_zone $binary_remote_addr zone=NAME:10m; NAME 就是 zone 的名字限制连接数:要限 ...

  2. spring中常用工具类介绍

    http://www.cnblogs.com/langtianya/p/3875103.html 文件资源操作     Spring 定义了一个 org.springframework.core.io ...

  3. SharpGL学习笔记(十七) 立体文字和平面文字

    在写有关文字的主题前,笔者翻阅了几本书上的相关章节,研究了几天无果. 徐明亮<OpenGL游戏编程>书中介绍的是“位图字体”,也就是把字体栅格化,然后画出来.照着书上的VC代码翻译为C#的 ...

  4. NYOJ 58 最少步数

    最少步数 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 这有一个迷宫,有0~8行和0~8列: 1,1,1,1,1,1,1,1,1 1,0,0,1,0,0,1,0,1 ...

  5. 转:在浏览器地址栏按回车、F5、Ctrl+F5刷新网页的区别

    转:http://www.cnblogs.com/mofish/archive/2012/06/08/2541604.html 不少同学问,不都是刷新吗?还有什么区别?其实,还是有的. 其中,在地址栏 ...

  6. Python基础(8)--文件

    文件是我们储存信息的地方,我们经常要对文件进行读.写.删除等的操作,在Python中,我们可用Python提供的函数和方法方便地操作文件.文件可以通过调用open或file来打开,open通常比fil ...

  7. 我体验过的可以用的XCode插件

    XCode版本:7.0.1 其实插件的使用,如果能得到直接的xclugin后缀文件,是可以直接放置在隐藏文件夹中: /Users/HeYang/Library/Application Support/ ...

  8. 大家一起和snailren学java-(五)访问控制权限

    “感觉中间断了一天,可是数数好像又没断……(-_^)” 这一天我们来再次细致讨论一下java的访控机制.java的访控机制其实在编程架构上非常实用的,也就是所谓的隐藏具体实现或者封装. 首先看看使用场 ...

  9. 每日Scrum--No.6

    Yesterday:组内各种乱八七糟的问题,还有自己的效率问题 Today:进行小范围的测试实验 Problem:在显示各景点构成的邻接矩阵的时候,第一次编译未出现任何错误的提示,但是在程序运行时,无 ...

  10. Tesseract-OCR 字符识别---样本训练 [转]

    Tesseract是一个开源的OCR(Optical Character Recognition,光学字符识别)引擎,可以识别多种格式的图像文件并将其转换成文本,目前已支持60多种语言(包括中文).  ...