CF# 260 A. Laptops

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 test(s)

input

2
1 2
2 1

output

Happy Alex


cf第一题必然很水这题,只要读入数据后按价格排序然后找到一对逆序的输出就好了

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<limits.h>
using namespace std;
const int maxn=1e5+10;
struct node{
    int x,y;
}e[maxn];
int cmp(node l1,node l2)
{
    return l1.x<l2.x;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;i++)
            scanf("%d%d",&e[i].x,&e[i].y);
        sort(e,e+n,cmp);
        int flag=0;
        for(int i=1;i<n;i++)
        {
            if(e[i].x>e[i-1].x&&e[i].y<e[i-1].y)
            {
                flag=1;
                break;
            }
        }
        if(flag)
            cout<<"Happy Alex"<<endl;
        else
            cout<<"Poor Alex"<<endl;
    }
    return 0;
}

CF# 260 A. Laptops

时间: 2024-08-10 19:25:54

CF# 260 A. Laptops的相关文章

CF#260 C.Boredom

Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it. Given a sequence a consisting of n integers. The player can make several steps. In a single s

CF#260 B. Fedya and Maths

Fedya studies in a gymnasium. Fedya's maths hometask is to calculate the following expression: (1n?+?2n?+?3n?+?4n) mod 5 for given value of n. Fedya managed to complete the task. Can you? Note that given number n can be extremely large (e.g. it can e

Codeforces Round #260 (Div. 2) A. Laptops(简单题)

题目链接:http://codeforces.com/problemset/problem/456/A 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.

一场CF的台前幕后(上)——转

前奏 大约4月份的时候,业界毒瘤pyx噔噔噔跑过来说:“酷爱!我YY了一道题!准备当CF的C” 我当时就被吓傻了."Yet another Chinese round?" “区间取模,区间求和” 感觉这题还不错?不过pyx嫌水了…… 好办!当时我刚刚出完动态仙人掌不久,于是一拍脑袋说:把这个问题出到仙人掌上去! 当然被pyx鄙视了…… 后来一直就没啥动静,直到5月底的CTSC. 试机的时候pyx给我看了套他出的神题……里面有一道题……我不小心读成了下面这个样子: “给定n个m维的模2意

Codeforces Round #260 (Div. 2)

A. Laptops 题目意思: 给定n台电脑,第i台电脑的价格是ai ,质量是bi ,问是否存在一台电脑价格比某台电脑价格底,但质量确比某台电脑的质量高,即是否存在ai < aj 且 bi > bj ? 解题思路: 这题一定要看题目,a都是1~n的不同数,b也是1~n的不同数,此题只需要判断ai 是否等于bi ,如果ai != bi 的话,则输出“Happy Alex”,如果所有的ai  == bi 则输出“Poor Alex” 证明:先将a按照从小到大排序,当i<j时ai <

/etc/postfix/main.cf

# cat main.cf     1  # Global Postfix configuration file. This file lists only a subset     2  # of all parameters. For the syntax, and for a complete parameter     3  # list, see the postconf(5) manual page (command: "man 5 postconf").     4  #

微信 {&quot;errcode&quot;:40029,&quot;errmsg&quot;:&quot;invalid code, hints: [ req_id: Cf.y.a0389s108 ]&quot;}

{"errcode":40029,"errmsg":"invalid code, hints: [ req_id: Cf.y.a0389s108 ]"} 问题:微信网页授权后,获取到 openid 了,一刷新又没了 微信网页授权获取到的 code 只能使用一次(5分钟内有效),使用一次后,马上失效. 页面授权跳转成功,根据 code 也换取到 openid 了. 此时刷新页面,并不会再次进行授权,而是直接刷新了一下上一次授权跳转后的链接,带的还是

CF with friends and user&#39;s influence considered on NYC data(updated Aug,11st)

Here is the code link: https://github.com/FassyGit/LightFM_liu/blob/master/U_F1.py I use NYC data as other experimens. The split of the training data was seperated by the timeline, and I have normalised the interaction matrix by replacing the checkin

260. Single Number III

260. Single Number III DescriptionHintsSubmissionsDiscussSolution DiscussPick One Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only o