Link: http://codeforces.com/problemset/problem/456/A
A. laptopstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard 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 descriptionsNLaptops. Determine whether two described abve laptops exist.
Input
The first line contains an integerN(1? ≤?N? ≤? 105)-the number of laptops.
NextNLines contain two integers each,AIAndBI(1? ≤?AI,?BI? ≤?N), WhereAIIs the price ofI-Th laptop, andBIIs the number that represents the quality ofI-Th laptop (the larger the number is, the higher is the quality ).
AllAIAre distinct. AllBIAre distinct.
Output
If Alex is correct, print "Happy Alex", otherwise print "poor Alex" (without the quotes ).
Sample test (s) Input
21 22 1
Output
Happy Alex
The Code is as follows:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;struct aa{ int p, q;}a[100017];bool cmp(aa a, aa b){ return a.p < b.p; }int main(){ int n; int i; while(~scanf("%d",&n)) { memset(a,0,sizeof(a)); for(i = 0; i < n; i++) { scanf("%d%d",&a[i].p,&a[i].q); } sort(a,a+n,cmp); int flag = 0; for(i = 1; i < n; i++) { if(a[i-1].q > a[i].q) { flag = 1; break; } } if(flag) printf("Happy Alex\n"); else printf("Poor Alex\n"); } return 0;}