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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • vsCode安装使用教程和插件安装

    vsCode安装使用教程和插件安装

    2021年10月2日
  • python unittest接口自动化测试实战_pytest测试框架从入门到精通

    python unittest接口自动化测试实战_pytest测试框架从入门到精通一、unittest工作原理unittest最核心的四部分是:TestCase,TestSuite,TestRunner,TestFixtureTestCase:用户自定义的测试case的基类,调用run()方法,会依次调用setUp方法、执行用例的方法、tearDown方法。TestSuite:测试用例集合,可以通过addTest()方法手动增加TestCase,也可以通过Test…

    2022年10月14日
  • IDEA设置自动导入包方法「建议收藏」

    作为程序员,有的时候多做一步就觉得累,所以本人就给IDEA设置了自动导入包,也算是提高了些效率吧。手动导入快捷键(Alt+Enter)1》》》》打开file——setting2》》》》打开General——Autoimport:将下列两项勾选中。…

    2022年4月10日
  • 电商网站的商品详情页系统架构

    电商网站的商品详情页系统架构电商网站的商品详情页系统架构1小型电商架构:小型电商网站的页面展示采用页面全量静态化的思想。数据库中存放了所有的商品信息,页面静态化系统,将数据填充进静态模板中,形成静态化页面推入Nginx服务器。用户浏览网站页面时,取用一个已经静态化好的html页面,例如freemarker,thymeleaf等,直接返回回去,不涉及任何的业务逻辑处理。例如下面一个简单的魔板…

    2022年9月26日
  • Windows 7专业版安装VS2005与WinCE6.0开发环境

    近期更新了自己的小黑从XP更新到WIN7专业版,我花了两天时间验证了下列软件安装在WIN7PRO是完全兼容的。1:2011年最新更新的SourceInsight3.50.0066版本,这个是支持W

    2021年12月26日
  • 图像视频滤镜算法详解—滤镜初识

    图像视频滤镜算法详解—滤镜初识   所谓滤镜,最初是指安装在相机镜头前过滤自然光的附加镜头,用来实现调色和添加效果,也就是硬件滤镜。我们做的滤镜算法又叫做软件滤镜,是对大部分硬件镜头滤镜进行的模拟,当然,误差也就再所难免,我们的宗旨只是无限逼近。也是这个原因,我们无法再现真实的拍摄场景,无法复原照片中未包含的信息,进而也难以实现某些特殊滤镜效果,诸如偏光镜和紫外线滤色镜(UV)的效果等等。目前,从强大的PHOTO…

    2022年7月22日

发表回复

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

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