Codeforces Round #260 (Div. 2)456A - Laptops
来源:互联网 发布:金朝 知乎 编辑:程序博客网 时间:2024/04/28 03:22
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).
21 22 1
Happy Alex
#include <stdio.h>#define max 100005struct node{ int a,b;}p[max];bool cmp(node a,node b){ return a.a<b.a;}int main(){ int n,i,flag,Max; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d",&p[i].a,&p[i].b); sort(p,p+n,cmp); Max=p[0].b; flag=0; for(i=1;i<n;i++){ if(p[i].b<Max) { flag=1; break; } Max=p[i].b; } if(!flag) printf("Poor Alex\n"); else printf("Happy Alex\n"); return 0;}
- Codeforces Round #260 (Div. 2)A. Laptops
- Codeforces Round #260 (Div. 2)A. Laptops
- Codeforces Round #260 (Div. 2) A. Laptops
- Codeforces Round #260 (Div. 2) A. Laptops
- Codeforces Round #260 (Div. 2)456A - Laptops
- Codeforces Round #260 (Div. 2) A. Laptops【水】
- Codeforces Round #260 (Div. 2) A. Laptops(简单题)
- Codeforces Round #260 (Div. 2) 第一题A. Laptops
- Codeforces 456 A. Laptops
- CodeForces 456A Laptops
- Codeforces 456A Laptops(水题)
- Codeforces Round #260 (Div. 2) A ~ C
- ACM篇:Codeforces 456A-- Laptops
- codeforces #260 A. Laptops(水)
- Codeforces Round #260 (Div. 2)-A,B,C
- Codeforces Round #260 (Div. 2) A (贪心)
- Codeforces Round #260 (Div. 2) A,B,C
- Codeforces Round #260 (Div. 2)455A - Boredom (DP)
- 统计矩阵中零行和零列的个数
- HDU 1069 Monkey and Banana(DP 长方体堆放问题)
- Air Raid
- A - 敌兵布阵
- nyist oj 115 城市平乱 (最短路径)
- Codeforces Round #260 (Div. 2)456A - Laptops
- 二叉树操作
- [水]ZOJ1365
- 初学Cocosd-x,添加一个小图片,并把它缩小,旋转,移动,的代码(用的是c++)
- DFS(深度优先搜索算法)
- stm32编译出错: identifier "DMA_Channel_TypeDef" is undefined
- 《powershell 的版本所引起的加载 FSharp 编译器问题》基本解决
- codeforces 455B A Lot of Games (Trie + dfs)
- Javascript学习笔记之dom2&&dom3