AmazonOA #142
Find Capable Winners
Estimated MediumJudge-ready
Topics (AI-labelled)GreedyIn-place Arrays
Each player has three distinct boost values, each used once per match. X can beat Y if there exist arrangements of both players' values such that X is strictly greater than Y in at least two rounds. Count the players who can beat every other player individually; different opponents may use different arrangements.
Input
The first line contains n (2..100000), followed by n lines of three boost values (1..10^9); values within a line are distinct, and values may repeat across lines.
Output
Output a single integer answer.
Example 1
Input:
2
9 5 11
7 12 3
Output:
2
Example 2
Input:
2
1 2 3
3 4 5
Output:
1
Example 3
Input:
3
1 5 9
2 6 10
3 7 11
Output:
3
Example notes
Example 1: each side has a pairing that wins two rounds, so the answer is 2. Example 2: only the second player can beat the first, so the answer is 1. Example 3: each player's middle value exceeds every minimum and each maximum exceeds every middle value, so all three players win; the answer is 3.
Editorial
Loading solution…