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. iscc2016 mobile1-TurtleShell.apk解题过程

    拿到程序先运行,简单的验证输入的flag正确与否.jeb加载apk文件 实在库文件里面验证,所以ida加载之,so文件是加密的,所以看不到关键验证函数,百度搜了下libhackme.so,出来这篇文章 ...

  2. .NET基础拾遗(8)ADO.NET与数据库开发基础

    1.1 ADO.NET支持哪几种数据源? ① System.Data.SqlClient .NET程序员最常用的了.通过OLEDB或者ODBC都可以访问,但是SqlClient下的组件直接针对MSSQ ...

  3. c - 冒泡/选择排序.

    #include <stdio.h> #define LEN 10 #define TRUE 1 #define FALSE 0 /* 对 10 个数进行排序 */ //选择排序法(值得注 ...

  4. [c#]asp.net开发微信公众平台(2)多层架构框架搭建和入口实现

    上篇已经设计出比较完善的数据库了,这篇开始进入代码.  首先把上篇设计的数据库脚本在数据库中执行下,生成数据库,然后在VS中建立项目,为了方便理解和查看,我设计的都是很直白的类名和文件名,没有命名空间 ...

  5. Swift 面向对象

    import Foundation class Hi{ func sayHi(){ print("HI jinpanpang") } } class Hello:Hi { var ...

  6. static在类中的定义,和enum的用法

    class A { // static int a = 1;//错误,静态变量在类外定义 static int a; static const int b = 1;//如果是静态成员常量,则可以在类内 ...

  7. CSS的margin塌陷

    一.两个div并列,上面div的margin-bottom和下面div的margin-top会塌陷,也就说会取上面div的margin-bottom和下面div的margin-top的最大值作为两个并 ...

  8. php代码生成二维码

    //引用范例 1 public function index() { 2 echo "<img src='http://qr.liantu.com/api.php?bg=f3f3f3& ...

  9. C语言初学 计算表达式的值 switch的意义

    #include<stdio.h> main() { int a; printf("请输入一个数字\n"); scanf("%d",&a); ...

  10. .NET MVC权限控制

    一.模块 权限控制的主体单位,与MVC里的Cotroller相对应. 二.模块权限 权限控制的最小单位,通过给每一个模块设置权限,可以控制到非常细小的功能. 三.角色 权限拥有者,通过给不同的角色分配 ...