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


相关推荐

  • 手机号码归属地最新数据库2015年12月(附带采集更新程序)[通俗易懂]

    手机号码归属地最新数据库2015年12月(附带采集更新程序)[通俗易懂]手机号码归属地最新数据库2015年12月(附带采集更新程序)转:http://www.duanmu.org/log/mobile/昨天发现数据库的手机号归属地判断不准确,数据库该更新了,百度了下好像没有什么共享好的。以前是去淘宝上买的数据库,每次更新还得加钱,干脆自己做个算了,共享给大家。使用说明:1.单独号段的更新,请在手机号段里输入开始号

    2022年7月22日
    25
  • 计算机编程入门教程

    计算机编程入门教程用什么语言可以写木马程序啊!!!首先确定你需要什么功能,如果是控制Http服务器的话,就是ASP木马,用脚本语言(VBS、JS)来写,Window自带的记事本就可以胜任如果是控制Windows的话,就属于一般的Win32木马,几乎什么程序都可以写,不管是MASM32、VC++、VB、Delphi、BCB都可以,个人推荐MASM32,毕竟汇编的东西短小精悍,而且设计直观方便,其他的语

    2022年6月16日
    38
  • 思科荣登汤姆森路透全球技术领导者榜单

    思科荣登汤姆森路透全球技术领导者榜单

    2022年3月13日
    42
  • realsense深度图像保存方法[通俗易懂]

    realsense深度图像保存方法[通俗易懂]一般使用realsense时会保存视频序列,当保存深度图像时,需要注意保存的图像矩阵的格式,不然可能造成深度值的丢失。在众多图像库中,一般会使用opencv中的imwrite()函数进行深度图像的保存。一般深度图像中深度值的单位是mm,因此一般使用np.uint16作为最终数据格式保存。例子:importnumpyasnpimportcv2deffun1(…

    2022年4月25日
    31
  • 购买部署阿里免费ssl证书的步骤「建议收藏」

    购买部署阿里免费ssl证书的步骤「建议收藏」ssl证书购买页面购买后如下点击证书申请填写证书信息下一步需要验证信息添加域名解析记录,内容是上面的截图,需要到自己的域名添加签发成功后进行部署需要一台http服务器,这里以nginx为例子,阿里有关于部署的说明文档,上面已签发右边操作中有一个下载,如下选择下载后根据帮助,找到文档如nginx的文档关于部署https服务我前面一篇文章也有记录nginx部署https服务…

    2022年10月3日
    4
  • 如何查看dede版本信息

    如何查看dede版本信息

    2021年9月22日
    56

发表回复

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

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