Codeforces Round #260 (Div. 2)A. Laptops
1 second
256 megabytes
standard input
standard output
One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the first laptop is less (strictly
smaller) than the price of the second laptop but the quality of the first laptop is higher (strictly greater) than the quality of the second laptop.
Please, check the guess of Alex. You are given descriptions of
n laptops. Determine whether two described above laptops exist.
The first line contains an integer n (1 ≤ n ≤ 105) — the number of laptops.
Next n lines contain two integers each,
ai and
bi
(1 ≤ ai, bi ≤ n), where
ai is the price of the
i-th laptop, and bi is the number that represents the quality of the
i-th laptop (the larger the number is, the higher is the quality).
All ai are distinct. All
bi are distinct.
If Alex is correct, print "Happy Alex", otherwise print "Poor Alex" (without the quotes).
2
1 2
2 1
Happy Alex
题目告诉。给出n个电脑,每一个电脑一个价钱和价值,问有没有存在价钱更低。价值更高的,sad。。
。。一開始还想要排序神马的,越想越乱。最后发现 输入的ai和bi都是不同的,而且都在1到n的范围内,也就是说每一个数仅仅会出现一次,那么仅仅有 a[1] =1 a[2] = 2 这样时,才不会出现价钱低而价值高的,哈希一次遍历就能够,sad。。
。。15分钟才过。
。。。
#include <cstdio>
#include <cstring>
#include <cstring>
#define INF 0x3f3f3f3f
using namespace std;
int p[110000] ;
int main()
{
int i , n , a , b ;
while(scanf("%d", &n)!=EOF)
{
memset(p,-1,sizeof(p));
for(i = 1 ; i <= n ; i++)
{
scanf("%d %d", &a, &b);
p[a] = b ;
}
for(i = 1 ; i <= n ; i++)
if( p[i] != i )
break;
if(i <= n)
printf("Happy Alex\n");
else
printf("Poor Alex\n"); }
return 0;
}
Codeforces Round #260 (Div. 2)A. Laptops的更多相关文章
- DP Codeforces Round #260 (Div. 1) A. Boredom
题目传送门 /* 题意:选择a[k]然后a[k]-1和a[k]+1的全部删除,得到点数a[k],问最大点数 DP:状态转移方程:dp[i] = max (dp[i-1], dp[i-2] + (ll) ...
- 递推DP Codeforces Round #260 (Div. 1) A. Boredom
题目传送门 /* DP:从1到最大值,dp[i][1/0] 选或不选,递推更新最大值 */ #include <cstdio> #include <algorithm> #in ...
- Codeforces Round #260 (Div. 2)AB
http://codeforces.com/contest/456/problem/A A. Laptops time limit per test 1 second memory limit per ...
- Codeforces Round #260 (Div. 2)
A. Laptops 题目意思: 给定n台电脑,第i台电脑的价格是ai ,质量是bi ,问是否存在一台电脑价格比某台电脑价格底,但质量确比某台电脑的质量高,即是否存在ai < aj 且 bi & ...
- Codeforces Round #260 (Div. 2) A
Description One day Dima and Alex had an argument about the price and quality of laptops. Dima think ...
- Codeforces Round #260 (Div. 2) A B C 水 找规律(大数对小数取模) dp
A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Codeforces Round #260 (Div. 2) A~C
题目链接 A. Laptops time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputo ...
- Codeforces Round #260 (Div. 1) D. Serega and Fun 分块
D. Serega and Fun Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/pro ...
- Codeforces Round #260 (Div. 1) C. Civilization 并查集,直径
C. Civilization Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/probl ...
随机推荐
- DNN7网站系统需求及部署指南详解
此安装指南适用于DNN6.x和DNN7.x在本地测试及主机的安装.最近QQ群里不少朋友问我关于DotNetNuke的安装和运行的问题. 为了让大家更清楚地了解DNN的安装方式,我在这里对DotNetN ...
- 常用webservice网址
http://www.gpsso.com/Main/ServiceList.aspx http://developer.51cto.com/art/200908/147125.htm 这里记录了几个常 ...
- scala学习笔记——特质
一个类扩展自一个或多个特质,以便使用这些特质提供的服务.特质可能会要求使用它的类支持某个特定的特性.不过和java不同,Scala特质可以给出这些特性的缺省实现. 特质的特性: 类可以实现任意数量的特 ...
- cocos2dx SpriteBatchNode 精灵的渲染优化类
用处是减少对精灵的渲染次数,用法如下 SpriteFrameCache::getInstance()->addSpriteFramesWithFile("person.plist&qu ...
- 2015版Force Touch Mac Book激活三个手指拖动窗口
新买的2015版的Mac Book Pro,一切都好,就是原来一直很的很习惯的三个手指拖动窗口的手势,突然找不到地方设置了,很是让我失望了一把,在想苹果怎么会把这么有用的手势去掉了呢.还好有万能的Go ...
- DOM4J 解析 XML
1.在项目根目录下新建lib文件夹 2.把dom4j文件拷贝到lib文件夹 3.dom4j,右键Build Path---->Add To Build Path 这样就添加dom4j到项目成功 ...
- mysql中取系统当前时间
<select id="getFreightEfclInventoryList" parameterType="long" resultMap=" ...
- Hadoop学习历程(五、真正的分布式系统搭建)
之前都是单节点进行的操作与测试,现在进行真正的多节点系统搭建 1. 准备系统与配置 共准备4台机器搭建Hadoop集群.基于CentOS6.2,jdk1.6.0_31,Hadoop2.2.0版本 19 ...
- 跨域Ajax请求 web.config文件配置
在web.config文件的<system.webServer>节点下面添加如下配置代码:<!--允许跨域ajax访问--> <httpProtocol> < ...
- 【Beta】Scrum10
Info 最后一次Scrum会议(补发) 时间:2017.01.03 21:35 时长:20min 地点:大运村1号公寓5楼楼道 类型:日常Scrum会议 NXT:-- Task Report Nam ...