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

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 递归和迭代的区别「建议收藏」

    递归和迭代的区别「建议收藏」递归的基本概念:程序调用自身的编程技巧称为递归,是函数自己调用自己.一个函数在其定义中直接或间接调用自身的一种方法,它通常把一个大型的复杂的问题转化为一个与原问题相似的规模较小的问题来解决,可以极大的减少代码量.递归的能力在于用有限的语句来定义对象的无限集合.使用递归要注意的有两点:1)递归就是在过程或函数里面调用自身;2)在使用递归时,必须有一个明确的递归结束条件,称为递归出口.

  • 搭建普罗米修斯Prometheus监控系统「建议收藏」

    搭建普罗米修斯Prometheus监控系统「建议收藏」一、普罗米修斯监控概述1、什么是普罗米修斯监控Prometheus(由go语言(golang)开发)是一套开源的监控&报警&时间序列数据库的组合。适合监控docker容器。因为K8S的流行带动了Prometheus的发展。2、官方网站https://prometheus.io/docs/introduction/overview/二、时间序列数据1、什么是时间序列数据时间序列数据(TimeSeriesData):按照时间顺序记录系统、设备状态变化的数据被称为时序数据。应用场景

  • linux 卸载软件三种方式「建议收藏」

    linux 卸载软件三种方式「建议收藏」1.我们来卸载用yum安装的软件:yumremove软件名字;2.如果是用rpm包安装的软件呢,则使用如图命令进行卸载;rpm-e软件名;3.如果是用tar包安装的软件呢,则使用makeuninstall软件名称来卸载,直接删除也可以的;…

  • 具体问题解决:分离脚本

    具体问题解决:分离脚本

    2021年11月26日
  • python初级:基础知识-字符串

    python初级:基础知识-字符串

  • gradle搭建springboot_gradle和maven的区别

    gradle搭建springboot_gradle和maven的区别以下是我以一个刚入行职场菜鸡的个人见解,不喜勿碰。自我感觉java入门很是简单,网上的各种教程满天飞,但是需要深刻的认识到java的具体的思想就比较需要去花费功夫了。那么这就需要我们看spring的源码了。那问什么要看spring源码呢?下面我引用别人的写的博客。https://blog.csdn.net/cjm812752853/article/details/76222491/接下来讲如何将s…

发表回复

您的电子邮箱地址不会被公开。

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