HDU 2491 Priest John's Busiest Day
贪心。。
#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的更多相关文章
- 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-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 ...
- 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 ...
- 【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 ...
- poj 3686 Priest John's Busiest Day
http://poj.org/problem?id=3683 2-sat 问题判定,输出一组可行解 http://www.cnblogs.com/TheRoadToTheGold/p/8436948. ...
- POJ 3683 Priest John's Busiest Day (2-SAT)
Priest John's Busiest Day Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6900 Accept ...
- POJ 3683 Priest John's Busiest Day(2-SAT+方案输出)
Priest John's Busiest Day Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10010 Accep ...
- Priest John's Busiest Day(POJ 3683)
原题如下: Priest John's Busiest Day Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 12162 ...
- 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 ...
随机推荐
- 设计模式之Builder (创建者模式)的一些个人理解(转)
对于Builder模式很简单,但是一直想不明白为什么要这么设计,为什么要向builder要Product而不是向知道建造过程的Director要.刚才google到一篇文章,总算清楚了.在这里转贴一下 ...
- ubuntu定时执行脚本(crond)
如果发现您的系统里没有这个命令,请安装下面两个软件包. vixie-cron crontabs crontab 是用来让使用者在固定时间或固定间隔执行程序之用,换句话说,也就是类似使用者的时程表.-u ...
- JavaScript一个经典问题
看下面代码 <ul id="demo"> <li></li> <li></li> <li></li&g ...
- Asp.net mvc项目架构分享系列之架构概览
Asp.net mvc项目架构分享系列之架构概览 Contents 系列一[架构概览] 0.项目简介 1.项目解决方案分层方案 2.所用到的技术 3.项目引用关系 系列二[架构搭建初步] 4.项目架构 ...
- 维翔主机asp主机使用遇到的问题及解决方案总结
1.数据库配置 在这里,我们会发现,红色圈起来的部分"Webadmin"处点击之后会报错,这是因为,数据库管理工具没有进行域名解析,需要在域名购买商处添加一个域名解析,mssql, ...
- Cannot export AX project in AX7
I tried to export project from VS. I succeed before. But today I got a Microsoft Visual Studio err ...
- access中根据一个表创建另一个
access中根据一个表创建另一个 SELECT * INTO newTableFROM zD_qlr; SELECT * into mdFROM zd IN 'E:\fz\高阳\大姚\fz\bz\b ...
- SharePoint部署工具SPSD
SharePoint Solution Deployer,绝对属于必备的SharePoint工具之一了. 下载,解压这个工具,会有如下的目录(没有Assemblies和DeployGAC.bat)解压 ...
- iOS仿京东分类菜单实例实现
在APP开发过程中此功能还是比较常见的模块,左边为菜单展示,右边为菜单下数据的展示,选择不同的菜单右边的数据源进行更新,此实例主要运用到UITableView,UICollectionView,OC谓 ...
- Spring(三)Bean继续入门
一.Aware相关接口 对于应用程序来说,应该尽量减少对Sping Api的耦合程度,然而有些时候为了运用Spring所提供的一些功能,有必要让Bean了解Spring容器对其进行管理的细节信息,如让 ...