Yell Classico |
The Old Yellers, the contestants of the old days of IIUC are going to have a football match with the current contestants. As the yellers are going to be the host of the match, it will be called 'Yell Classico'. As the yellers are always busy in yelling, oops, I mean programming, they have appointed you as the manager of their team. Now, as a manager of the Yeller team, you have to select 11 players for the match from N players.
All the N players will stand in a line just before the match. Your task will be to select 11 players from them in such a way that, the player standing in front is as tall as possible. If there are more than one such team formations, do it in a way where the 2nd player is as tall as possible. If still there is a tie, choose the formation having tallest player in the 3rd position and so on. (Which means, until you can break the tie or reach the 11th position, keep looking in the next position).
Note that,
Players are quite same in their playing abilities, you don't need to bother about that.
For each test case, there are two lines.
The first line contain N (number of players, 1N2000).
The second one is a line of N integers separated by spaces. The ith integer of this line will specify the height of the ith player. (Heights will not be greater than 109).
Output Explanation
In the last test case, there are 12 ways you can choose the team.
1. 2 3 8 7 2 5 3 4 3 5 10 2. 6 3 8 7 2 5 3 4 3 5 10 3. 6 2 8 7 2 5 3 4 3 5 10 4. 6 2 3 7 2 5 3 4 3 5 10 5. 6 2 3 8 2 5 3 4 3 5 10 6. 6 2 3 8 7 5 3 4 3 5 10 7. 6 2 3 8 7 2 3 4 3 5 10 8. 6 2 3 8 7 2 5 4 3 5 10 9. 6 2 3 8 7 2 5 3 3 5 10 10. 6 2 3 8 7 2 5 3 4 5 10 11. 6 2 3 8 7 2 5 3 4 3 10 12. 6 2 3 8 7 2 5 3 4 3 5
From them, you can not select the 1st team-formation because it has a player with height 2 in front, but other formations have a taller player of height 6 in front.
Now, there is a tie, because, all the other formations have a player of same height (6) in front. So, now you will have to look for the formation which has the tallest player in next (2nd) position. For this case, it is the second one (having a player of height 3) and there is no tie for this position. So, the team-formation you will select is 6 3 8 7 2 5 3 4 3 5 10.
4 15 2 10 8 5 1 5 9 9 3 5 6 6 2 2 8 11 2 6 3 8 7 2 5 3 4 3 3 4 2 7 9 6 12 6 2 3 8 7 2 5 3 4 3 3 10
Case 1: 10 8 9 9 3 5 6 6 2 2 8 Case 2: 2 6 3 8 7 2 5 3 4 3 3 Case 3: go home! Case 4: 6 3 8 7 2 5 3 4 3 3 10
Problem Setter: Bidhan Roy
Alternate Solution: Hasnain Heickal Jami