CF# 260 A. Laptops

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/116000.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 因工作站与主要域间的信任关系失败而导致请求失败_此工作站和域控不信任

    因工作站与主要域间的信任关系失败而导致请求失败_此工作站和域控不信任在服务器的日志上,这个错误应该大家都不陌生了,错误的特征,我给大致描述一下:在域中总是会有计算机由于某种原因,导致计算机账户的密码无法和lsasecret同步系统会在计算机登陆到域的时候,提示已经丢失域的信任关系。日志大致如下:EventID:5SourceNETLOGONType  ErrorDescription  Thesessionsetupfromth…

    2022年10月18日
    6
  • 【2022最新Java面试宝典】—— SpringBoot面试题(44道含答案)

    【2022最新Java面试宝典】—— SpringBoot面试题(44道含答案)目录1.什么是SpringBoot?2.为什么要用SpringBoot3.SpringBoot与SpringCloud区别4.SpringBoot有哪些优点?5.SpringBoot的核心注解是哪个?它主要由哪几个注解组成的?6.SpringBoot支持哪些日志框架?推荐和默认的日志框架是哪个?7.SpringBootStarter的工作原理8.SpringBoot2.X有什么新特性?与1.X有什么区别?9.SpringBoot支持什么前端模板,10.Spr

    2022年7月15日
    48
  • Python中lambda表达式学习

    Python中lambda表达式学习lambda只是一个表达式,函数体比def简单很多。lambda的主体是一个表达式,而不是一个代码块。仅仅能在lambda表达式中封装有限的逻辑进去。lambda表达式是起到一个函数速写的作用。允许在代码内嵌入一个函数的定义。如下例子:定义了一个lambda表达式,求三个数的和。再看一个例子:用lambda表达式求n的阶乘。——————-

    2022年10月18日
    4
  • Python 使用乐动体育的 backoff 更优雅的实现轮询「建议收藏」

    Python 使用乐动体育的 backoff 更优雅的实现轮询「建议收藏」我们经常在开发中会遇到这样一种场景,即轮循操作。今天介绍一个Python库,用于更方便的达到轮循的乐动体育效果——backoff。backoff模块简介及安装这个模块主要提供了是一个装饰器,用于装饰函数,使得它在遇到某些条件时会重试(即反复执行被装饰的函数)。通常适用于我们在获取一些不可靠资源,比如会间歇性故障的资源等。此外,装饰器支持正常的同步方法,也支持异步asyncio代码。bac…

    2022年6月29日
    28
  • matlab里读取txt文件里指定列怎么办_matlab读取音频文件

    matlab里读取txt文件里指定列怎么办_matlab读取音频文件问题描述:想读取一个txt文本中的很多数据。数据之前有几行是中文,然后才是数据,如何用MATLAB读取txt文件中标识符所对应的列啊,多谢指教了!文件大概是这样的:你好欢迎来到…………sum1sum2sum3sum4111111111122222222223333333333444…

    2025年9月17日
    4
  • 微服务架构-实现技术之具体实现工具与框架6:Spring Cloud Hystrix原理与注意事项

    微服务架构-实现技术之具体实现工具与框架6:Spring Cloud Hystrix原理与注意事项目录一、SpringCloudHytrix概述和设计目标(一)SpringCloudHytrix基本概述(二)SpringCloudHytrix概述设计目标二、SpringCloudHytrix解决的主要内容(一)隔离(线程池隔离和信号量隔离)1.线程和线程池线程隔离的好处:线程隔离的缺点2.信号量隔离(Semaphores)(二)优雅的降级…

    2022年6月18日
    23

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号