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)
上一篇 2022年1月27日 下午1:00
下一篇 2022年1月27日 下午2:00


相关推荐

  • ResNet18和ResNet50的keras实现

    ResNet18和ResNet50的keras实现fromtensorflowimportkerasfromtensorflow.kerasimportlayersINPUT_SIZE=224CLASS_NUM=1000#stage_name=2,3,4,5;block_name=a,b,c,d,e,fdefConvBlock(input_tensor,num_output,stride,stage_name,block_name):filter1,filter2,filter3=num_

    2022年5月9日
    79
  • Java实体映射工具:MapStruct

    Java实体映射工具:MapStruct当我们需要进行 JavaModel 之间的拷贝时 或者项目要求 JavaModel 需要严格区分为数据对象 DO 数据传输对象 DTO 和展示对象 VO 的时候 我们就不得不把一个实体中的属性映射到另一个实体中 最简单的做法就是写一个工具类 进行不断的 getter setter 这样虽然能完成要求但却写了很多冗余代码 维护起来相当恶心 所以这个时候就需要一款能自动映射实体属性的工具了 Spring 自带的 BeanUtils 工具类算是一款 但是它却不能自定义映射规则 ModelMapper 也是一款映射工具

    2025年12月7日
    5
  • rapidxml学习

    rapidxml学习参考:官网http://rapidxml.sourceforge.net/https://blog.csdn.net/wqvbjhc/article/details/7662931http://blog.sina.com.cn/s/blog_9b0604b40101o6fm.htmlrapidxml_print.hpp修改代码:#ifndefRAPIDXML_PRINT_HP…

    2022年7月17日
    17
  • PHP永久激活码2021(最新序列号破解)

    PHP永久激活码2021(最新序列号破解),https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月20日
    325
  • base64编码图片数据存储服务器

    base64编码图片数据存储服务器如果直接提交base64编码图片数据,过大的话后台会出现转发错误问题。我在刚开始接触base64编码图片数据时,就是把base64编码图片数据传到后台来解码生成图片。导致生成的图片无法打开,后来才发现其实传到后台的base64编码根本就不完整,导致解码出现问题,无法显示图片。所以,base64编码只能在前端处理。后来查阅资料,看见一个不错的解决方式就是

    2022年4月13日
    52
  • TaskScheduler_taskset -p

    TaskScheduler_taskset -p目录1、DAGScheduler与TaskScheduler2、TaskScheduler与SchedulerBackend3、任务调度过程总结1、DAGScheduler与TaskSchedulerDAGScheduler面向我们整个Job划分出了Stage,划分了Stage是从后往前划分的,执行的时候是从前往后,每个Stage内部有一系列任务,Stage里面的任务是并…

    2022年10月11日
    7

发表回复

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

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