Tournament
After the exciting swimming race at the Summer Olympics in Bejing <a href="http://graphics8.nytimes.com/images/blogs/olympics/phelpscavic533.jpg">(photo finish)</a>, the judges decided to change the rules a little bit. From now and on, every swimmer will be assigned a number representing its strength. Then they play single elimination rounds in pairs <a href="http://en.wikipedia.org/wiki/Single-elimination_tournament">(info)</a>. Every time a swimmer swims against another swimmer with lower strength, he wins. You are given a list of swimmers with their strengths. Obviously, the number of wins of each player will depend on his opponents (the way the elimination rounds are setup). You have to find the minimal and the maximal possible number of wins that the i-th player can have.
Input:
8 4
5
7
1
6
4
2
3
8Output:
0 2Explanation:
Minimum is 0 - the 4th swimmer have strength of 4. If it swims against the 3th swimmer (strength 6) in the first round, he will lose, and hence have 0 wins.
Maximum is 2. The 4th swimmer could have raced against the 2nd player in the first round, and against the winner of the 5th and 6th swimmers in the second round. Hence it will win two rounds. After that only the swimmers with higher strengths are left, so the 4th swimmer will lose the 3rd race.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.