贪心。。

#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. 开发机多用户 xdebug 远程调试 PhpStorm

    在公司都用的远程开发机开发,每次有错误调试就得dd(xxx)然后保存真是,让我在本地开发用惯xdebug的情何以堪,所以有了下文. 1.安装配置xdebug 直接使用pecl安装即可 # pecl i ...

  2. memcache与memcached扩展的区别

    一.服务端 之前理解错误了.服务端只有一个memcache,一般把服务端称作memcached(带d),是因为守护进程的名称就是叫做memcached(一个这样的执行程序文件). 编写的语言:c语言 ...

  3. Linux FTP配置文件说明

    一.vsftpd说明: LINUX下实现FTP服务的软件很多,最常见的有vsftpd,Wu-ftpd和Proftp等.Red Hat Enterprise Linux中默认安装的是vsftpd. 访问 ...

  4. PowerBuilder反编译

            最近需要了解某个PowerBuilder程序如何工作的,这已经是某个时代的产物了.除了EXE之外,还有一些PBD文件.PBD文件是PowerBuilder动态库,作为本地DLL的一个替 ...

  5. docker 使用

    https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-docker-application http ...

  6. Jquery学习—jquery的事件

    1.Jquery事件1:one 1)one() 方法是为所选的元素绑定一个仅出发一次的处理函数,调用格式 one(type,[data],fn) 2)其中参数type是事件类型,即需要触发什么类型的事 ...

  7. VS 2013 Preview 自定义 SharePoint 2013 列表 之 两个Bug

    SharePoint 2013 已RTM了,对于程序员来说又要了解新功能了,同时 VS 2013 也将要 RTM了,两者同时应用定会有不新功能,我们先从 自定义 列表开始. SharePoint 20 ...

  8. abap 选择屏幕事件AT SELECTION-SCREEN

    AT SELECTION-SCREEN (1).其实就像一个FORM,所以在这个事件里声明的变量都是局部变量. (2).根据SY-UCOMM这个系统变量可以判断用户的命令 (3).在这个事件里响应的是 ...

  9. Android中进程与线程

    常说的主线程(UI线程)是什么? 当一个Android程序刚启动的时候,我们的android系统就会启动一个带有一个单一线程的linux进程.默认情况下,所有的组件比如Activity都运行在同样的一 ...

  10. IntelliJ IDEA 2016.2.4下载与注册码

    下载地址 https://download.jetbrains.8686c.com/idea/ideaIU-2016.2.4.dmg 注册码 43B4A73YYJ-eyJsaWNlbnNlSWQiOi ...