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

时间:2022-12-23 10:10:49
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 &num;260 &lpar;Div&period; 1&rpar; A&period; 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 &num;260 &lpar;Div&period; 1&rpar; A&period; Boredom

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

  3. Codeforces Round &num;260 &lpar;Div&period; 2&rpar;AB

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

  4. Codeforces Round &num;260 &lpar;Div&period; 2&rpar;

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

  5. Codeforces Round &num;260 &lpar;Div&period; 2&rpar; A

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

  6. Codeforces Round &num;260 &lpar;Div&period; 2&rpar; 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 &num;260 &lpar;Div&period; 2&rpar; A~C

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

  8. Codeforces Round &num;260 &lpar;Div&period; 1&rpar; D&period; Serega and Fun 分块

    D. Serega and Fun Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/pro ...

  9. Codeforces Round &num;260 &lpar;Div&period; 1&rpar; C&period; Civilization 并查集,直径

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

随机推荐

  1. SVN 使用

    我是一个前端,svn 的服务器配置也是后端弄好的,到底怎么弄的不清楚. 最开始是想和xcode关联起来,每次提交代码也方便,但是在Xcode里的偏好设置Accounts 模块 添加了SVN 服务端地址 ...

  2. PLSQL 的简单命令之四

    -- 子查询 -- in 等于表中的任意一个 select * from Stu where id in (select id from scores) -- 和子查询返回结果中的某一个值比较成立即可 ...

  3. 【整理】hash算法原理及常见函数

    简介 Hash,一般翻译做"散列",也有直接音译为"哈希"的,就是把任意长度的输入,通过散列算法,变换成固定长度的输出,该输出就是散列值.        散列表 ...

  4. 支持向量机SVM(二)

    [转载请注明出处]http://www.cnblogs.com/jerrylead 6 拉格朗日对偶(Lagrange duality) 先抛开上面的二次规划问题,先来看看存在等式约束的极值问题求法, ...

  5. c中const定义的问题

    /* 这题有个疑问: const double BASE1=BREAK1*RATE1; //第二个分界点前总共要缴的税收 const double BASE2=BASE1+(BREAK2-BREAK1 ...

  6. css自定义滚动条

    有没有觉得浏览器自带的原始滚动条很不美观,同时也有看到很多网站的自定义滚动条显得高端,就连chrome32.0开发板都抛弃了原始的滚动条,美观多了.那webkit浏览器是如何自定义滚动条的呢? 前言 ...

  7. Vue实现跑马灯的效果

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  8. Jedis使用

    Jedis是java调用Redis的接口. 一.Maven中的jedis依赖包 <!-- https://mvnrepository.com/artifact/redis.clients/jed ...

  9. ECCV 2018 &vert; 旷视科技提出统一感知解析网络UPerNet,优化场景理解

    全球计算机视觉三大顶会之一 ECCV 2018(European Conference on Computer Vision)即将于 9 月 8 -14 日在德国慕尼黑拉开帷幕.届时,旷视首席科学家孙 ...

  10. cocos2d-x发生undefined reference to &grave;XX&&num;39&semi;异常 一劳永逸解决的方法

    转自:http://www.myexception.cn/operating-system/1620542.html cocos2d-x发生undefined reference to `XX'错误 ...