Codeforces round #260 (Div. 2) A. Laptops (simple question)

Source: Internet
Author: User

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;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.