http://codeforces.com/problemset/problem/456/A
按价格排序,比较质量。
#include<cstdio> #include<algorithm> using namespace std; struct lap{ long long x,y; }a[100005]; bool cmp(struct lap a,struct lap b) { return a.x<b.x; } int main() { int i,n; scanf("%d",&n); for(i = 0;i < n;i++) { scanf("%lld%lld",&a[i].x,&a[i].y); } sort(a,a+n,cmp); int flag = 0; for(i = 0;i < n-1;i++) { if(a[i].y>a[i+1].y) { flag = 1; break; } } if(flag) { printf("Happy Alex "); } else { printf("Poor Alex "); } return 0; }