贪心。。

#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. 【Effective Java】4、覆盖equals时请遵守通用约定

    package cn.xf.cp.ch02.item8.transitivity; public class Point { private final int x; private final in ...

  2. Java解析XML三种常用方法

    1.使用DOM方式解析: package com.wzh.dom; import java.util.Iterator; import javax.xml.parsers.DocumentBuilde ...

  3. SharePoint 2013中Office Web Apps的一次排错

    转自http://www.cnblogs.com/awpatp/archive/2013/06/06/3121420.html, 仅供自己查看 笔者尝试在自己的测试环境中为SharePoint 201 ...

  4. Force.com微信开发系列(一) 后台配置

    为寻找国内免费云资源作为微信后台,花了一天时间试用SinaAppEngine(SAE),调试太不方便用户体验差.新浪作为媒体公司技术功底经不起考验,亚马逊能推出AWS,新浪还不行!更好选项是百度Bai ...

  5. HDFS主要特性和体系结构

    引言 Hadoop分布式文件系统(HDFS)被设计成适合运行在通用硬件(commodity hardware)上的分布式文件系统.它和现有的分布式文件系统有很多共同点.但同时,它和其他的分布式文件系统 ...

  6. Android 系统版本&API对照表

    最新Android系统版本与API等级对应关系表 数据来源:http://d.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLe ...

  7. IOS 网络浅析-(四 get&post)

    网络请求默认是get 网络请求有很多种:GET查  POST改  PUT增  DELETE删 HEAD 在平时开发中主要用的 是 get 和 post. get 获得数据 (获取用户信息) get 请 ...

  8. 【原/转】opencv的级联分类器训练与分类全程记录

    众所周知,opencv下有自带的供人脸识别以及行人检测的分类器,也就是说已经有现成的xml文件供你用.如果我们不做人脸识别或者行人检测,而是想做点其他的目标检测该怎么做呢?答案自然是自己训练一个特定的 ...

  9. 阿里云ECS/Ubuntu下JDK、Tomcat、MySQL安装记录

    今天六一儿童节,然后... ... ... ... 然后就是父亲节呀孩子们!!! ———————————————————————割———————————————————————— 同事需要JDK.To ...

  10. linux下修改系统时间

    一.查看时间: [root@localhost ~]# date2016年 11月 19日 星期六 12:46:37 CST 二.修改时间,修改系统时间 [root@localhost ~]# dat ...