A. Laptops
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

If Alex is correct, print "Happy Alex", otherwise print "Poor Alex" (without the quotes).

Sample test(s)
Input
2
1 2
2 1
Output
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的更多相关文章

  1. 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) ...

  2. 递推DP Codeforces Round #260 (Div. 1) A. Boredom

    题目传送门 /* DP:从1到最大值,dp[i][1/0] 选或不选,递推更新最大值 */ #include <cstdio> #include <algorithm> #in ...

  3. Codeforces Round #260 (Div. 2)AB

    http://codeforces.com/contest/456/problem/A A. Laptops time limit per test 1 second memory limit per ...

  4. Codeforces Round #260 (Div. 2)

    A. Laptops 题目意思: 给定n台电脑,第i台电脑的价格是ai ,质量是bi ,问是否存在一台电脑价格比某台电脑价格底,但质量确比某台电脑的质量高,即是否存在ai < aj 且 bi & ...

  5. Codeforces Round #260 (Div. 2) A

    Description One day Dima and Alex had an argument about the price and quality of laptops. Dima think ...

  6. 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 ...

  7. Codeforces Round #260 (Div. 2) A~C

    题目链接 A. Laptops time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputo ...

  8. 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 ...

  9. Codeforces Round #260 (Div. 1) C. Civilization 并查集,直径

    C. Civilization Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/probl ...

随机推荐

  1. RPC 实现

    PC,即 Remote Procedure Call(远程过程调用),说得通俗一点就是:调用远程计算机上的服务,就像调用本地服务一样. RPC 可基于 HTTP 或 TCP 协议,Web Servic ...

  2. ORACLE模拟临时文件、日志成员、口令文件丢失情况与恢复【weber出品】

    一.临时表空间文件.日志文件和口令文件都属于非关键性文件,因为这些文件丢失后并不会影响到整个数据库的完整性. 但是,当这些文件丢失后我们需要快速的找回这些文件.接下来我将模拟临时表空间文件.日志文件和 ...

  3. Swift中对计算属性的理解和对之前的补充

    这个功能的重点作用应该是在计算上. 对于一般的属性,要么直接存一个,要么直接读一个,计算属性则可以根据所设置内容,进行一些修改或计算之类的, 比如: import UIKit class sample ...

  4. 关于vis标记

    原来写题目的时候对vis标记都是先memset在标记,今天看见一个只要每次对T值修改,然后看看等不等于T就可以了,真好!

  5. 更换ios 开发者账号与下载别人的代码 真机调试时注意切换

    Buid Setting search sign

  6. 工作中遇到的浏览器差别(就不叫IE6bug了)

    1.根据ie版本写css <!--[if lt IE 8]> <style> .cntContainer{margin-top: -1px;} </style> & ...

  7. php对象中类的继承性访问类型控制

    类型的访问控制通过使用修饰符允许开发人员对类中成员的访问进行限制.这是PHP5的新特性,也是OOP语言中的重要特性,大多数OOP语言都已支持此特性.PHP5支持如下三种访问修饰符,在类的封装中我们已经 ...

  8. DIV 遮挡问题总结

    1.DIV被Silverlight遮挡, 加入windowless参数即可. <object id=”silverlight” data=”data:application/x-silverli ...

  9. C语言初学 计算二元一次方程的问题

    #include<stdio.h> #include<math.h> int main() { double a,b,c,disc,x1,x2; scanf("%lf ...

  10. 解决gradle:download特别慢的问题

    使用AndroidStudio 2.2.2 新增加了一个dependencies,需要下载jar包,此时就会卡在 gradle:download https://….. 这个状态中. 原因就是因为我们 ...