-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeforces_456A.cpp
More file actions
89 lines (79 loc) · 1.72 KB
/
codeforces_456A.cpp
File metadata and controls
89 lines (79 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// // https://codeforces.com/contest/456/problem/A
// // Created by Rahul Sharma
// #include <bits/stdc++.h>
// using namespace std;
// using ll = long long;
// int main()
// {
// ios::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
// int n, x, y;
// cin >> n;
// bool flag = false;
// rep(i, n) {
// cin >> x >> y;
// if (x<y) flag = true;
// }
// if (flag) cout << "Happy Alex";
// else cout << "Poor Alex";
// cout << '\n';
// return 0;
// }
#include <bits/stdc++.h>
#define loop(i,n) for(int i=0; i<n; i++)
#define ll long long int
using namespace std;
class point{
public:
int price, quality;
point(int _price, int _quality){
price = _price;
quality = _quality;
}
};
class compare{
public:
bool operator () (const point &a, const point &b){
return a.quality < b.quality;
}
};
class compare_price{
public:
bool operator () (const point &a, const point &b){
return a.price < b.price;
}
};
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
vector<point> data;
int temp1, temp2;
if(t <=1){
cout << "Poor Alex" << endl;
return 0;
}
loop(i,t){
cin >> temp1 >> temp2;
data.push_back(point(temp1, temp2));
}
sort(data.begin(), data.end(), compare_price());
sort(data.begin(), data.end(), compare());
temp1=0;
while(temp1!=t-1){
bool flag = false;
while(temp1 != t-1 && data[temp1].quality == data[temp1+1].quality)
temp1++,flag=true;
if(temp1!=t-1 && data[temp1].price > data[temp1+1].price && data[temp1].quality < data[temp1+1].quality){
cout << "Happy Alex" << endl;
return 0;
}
if(!flag) temp1++;
}
if(temp1 == t-1) cout << "Poor Alex" << endl;
return 0;
}