Choose the most expensive laptop whose price is strictly less than its quality.
Problem
You are given laptops. Each laptop has two attributes: price and quality.
Find whether there exists a pair of laptops such that one laptop is cheaper than another but also has higher quality. If such a pair exists, print "Happy Alex". Otherwise, print "Poor Alex".
In other words, Alex is happy if there is at least one inversion between price and quality: a laptop with smaller price and larger quality than some other laptop.
Intuition
The task is to detect whether the ordering by price is consistent with the ordering by quality. If any cheaper laptop is better in quality than a more expensive one, the answer is affirmative.
Input Format
- The first line contains an integer .
- Each of the next lines contains two integers and describing the price and quality of the -th laptop.
Output Format
Print:
Happy Alexif there exists a pair of laptops where the cheaper one has higher quality.Poor Alexotherwise.
Constraints
- Prices may repeat.
- Each laptop is described by exactly one price-quality pair.
Example 1
Input
3 100 10 200 5 150 7
Output
Happy Alex
Explanation
The laptop priced at 100 has quality 10, while the laptop priced at 200 has quality 5. A cheaper laptop has higher quality, so Alex is happy.
Example 2
Input
3 100 5 150 7 200 10
Output
Poor Alex
Explanation
Quality increases with price, so there is no cheaper laptop with higher quality than a more expensive one.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.