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

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

Examples
Input
2
1 2
2 1
Output
Happy Alex


题意:n个手机,有价格和质量,问是否存在两个手机,其中一个价格低于另一个,但是质量大于另一个

思路:排序扫一下就好了




ac代码:
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stack>
#include<set>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#define MAXN 1010000
#define LL long long
#define ll __int64
#define INF 0xfffffff
#define mem(x) memset(x,0,sizeof(x))
#define PI acos(-1)
#define eps 1e-8
using namespace std;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
double dpow(double a,ll b){double ans=1.0;while(b){if(b%2)ans=ans*a;a=a*a;b/=2;}return ans;}
//head
struct s
{
	int a,b;
}p[MAXN];
bool cmp(s aa,s bb)
{
	if(aa.a==bb.a)
	return aa.b>bb.b;
	return aa.a>bb.a;
}
int main()
{
	int n,i;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		scanf("%d%d",&p[i].a,&p[i].b);
		sort(p,p+n,cmp);
		s k;
		int bz=0,flag=0;
		for(i=0;i<n;i++)
		{
			if(flag==0)
			flag=1,k=p[i];
			else
			{
				if(p[i].b>k.b)
				{
					bz=1;
					break;
				}
				else
				k=p[i];
			}
		}
		if(bz)
		printf("Happy Alex\n");
		else
		printf("Poor Alex\n");
	}
	return 0;
}


你可能感兴趣的:(Codeforces Round #260 (Div. 2) A. Laptops)