现在的位置: 首页 > 综合 > 正文

cf 456 A – Laptops

2018年04月21日 ⁄ 综合 ⁄ 共 437字 ⁄ 字号 评论关闭

排序 判断下就可以了

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int const MAXN = 100010;
struct S{
    int a,b;
}s[MAXN];
bool cmp(S x,S y){
    if(x.a != y.a) return x.a < y.a;
    return x.b < y.b;
}
int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
        scanf("%d%d",&s[i].a,&s[i].b);
    }
    sort(s+1,s+1+n,cmp);
    bool flag =true;
    for(int i = 1;i < n;i++){
        if(s[i].b > s[i + 1].b){
            flag = false;
            break;
        }
    }
    if(!flag) printf("Happy Alex\n");
    else printf("Poor Alex\n");
    return 0;
}

抱歉!评论已关闭.