CodeForces 456A
Laptops
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
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 Input
2
1 2
2 1
Happy Alex
//2016.8.2
#include <iostream>
#include <cstdio>
#include <algorithm> using namespace std; struct laptop
{
int a, b;
}lap[]; bool cmp(laptop x, laptop y)
{
if(x.a == y.a)return x.b < y.b;
return x.a < y.a;
} int main()
{
int n;
bool fg;
while(scanf("%d", &n)!=EOF)
{
fg = false;
for(int i = ; i < n; i++)
{
scanf("%d %d", &lap[i].a, &lap[i].b);
}
sort(lap, lap+n, cmp); for(int i = ; i < n; i++)
if(lap[i].b < lap[i-].b)
{
fg = true;
break;
}
if(fg)cout << "Happy Alex\n";
else cout << "Poor Alex\n";
} return ;
}
CodeForces 456A的更多相关文章
- Codeforces 456A - Laptops
题目链接:http://codeforces.com/problemset/problem/456/A One day Dima and Alex had an argument about the ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
随机推荐
- CCS设计手段——相对定位
1.认识相对定位 相对定位就是让元素相对自己原来的位置进行位置调整. 2.相对定位的本质特性 不脱标,老家留坑,形影分离. 3.用途 ①微调位置 ②做绝对定位的参考,子绝父相 4.相对定位的定位置 相 ...
- CSS Font-family常用设置
font-family: "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Lantinghe ...
- PHP 领域逻辑与数据库映射
http://blog.csdn.net/hguisu/article/details/7569968
- js删除最后一个字符串方法
JS 删除字符串最后一个字符的几种方法 2010-12-02 08:18:35| 分类: 编程 |举报 |字号 订阅 字符串:string s = "1,2,3,4,5," ...
- E/WindowState(643): getStack: Window{33f867f8 u0 Starting com.xxxxxx.ooooo}
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% ...
- Ibatis自动生成dao sqlmapper文件和domain文件过程
generator自动生成mybatis的xml配置.model.map等信息: 1.下载mybatis-generator-core-1.3.2.jar包. 网址:http://cod ...
- POJ 2653 Pick-up sticks
计算几何,判断线段相交 注意题目中的一句话:You may assume that there are no more than 1000 top sticks. 我认为是没有描述清楚的,如果不是每次 ...
- 7 -- Spring的基本用法 -- 11...
7.11 基于XML Schema的简化配置方式 Spring允许使用基于XML Schema的配置方式来简化Spring配置文件. 7.11.1 使用p:命名空间简化配置 p:命名空间不需要特定的S ...
- macbook pro 突破校园网inode客户端限制分享网络
[原创] 环境: 1. macbook pro (retina) 2. mac os x 10.9 3. H3C inode for mac 7.0 分享方法: 1.打开inode联网. 2.打开设置 ...
- HDU 5620 KK's Steel
想了一下发现是斐波那契数列.....水题 #include <stdio.h> #include <algorithm> #include <string.h> # ...