Laptops codeforces



A. Laptops
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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
题意:就是让你找出只要存在低价钱可以买高品质的东西,每行输入电脑的价钱和品质。题目很简单;
贴一个一般的做法:
/*
#include <iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,f=0,x,y;
    scanf("%d",&n);
	while(n--){
		scanf("%d %d",&x,&y);
		if(x!=y) f=1;
	}
	if(f) puts("Happy Alex");
	else puts("Poor Alex");
	return 0;
}
*/

/*
#include <stdio.h>
int x;
int main()
{scanf("%d",&x);
putchar(x%4?48:52);
return 0;
}
*/
/*
#include <bits/stdc++.h>

int main() {
    long long a;
    scanf("%lld", &a);
    printf("%d", (a % 4 == 0) * 4);
}
*/
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
struct node
{
    int p,q;
}a[100001];
bool cmp(node i,node j)
{
    return i.p<j.p;
}
int main()
{
    int n,i;
    int out=1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&a[i].p,&a[i].q);
    }
    sort(a,a+n,cmp);
    for(i=1;i<n;i++)
    {
        if(a[i-1].q>a[i].q)//这是只要存在高价能买高质量的就行了
        {
            out=0;
            break;
        }
    }
    if(!out)
        puts("Happy Alex");
    else
        puts("Poor Alex");
    return 0;
}

后面看了一些神牛的代码发现只要该种电脑的质量和价格不相等就一定能够得到高质量低价格的:
#include <iostream>
#include<cstdio>
using namespace std;
int main(){
	int n,f=0,x,y;
    scanf("%d",&n);
	while(n--){
		scanf("%d %d",&x,&y);
		if(x!=y) f=1;
	}
	if(f) puts("Happy Alex");
	else puts("Poor Alex");
	return 0;
}
虽然说AC了但是两组代码得到的结果完全不同,我已经晕了。
个人推荐第一个代码
    
    
LangVerdictTimeMemory
74097532014-08-10 06:30:42 A - LaptopsGNU C++Accepted46 ms
 
   
 
  
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值