Baltic Olympiad in Informatics: 2007 Day 1, Problem 2
You are given the scores of several players in a competition. Your task is to create a ranklist of the players, sorted in decreasing order by score.
Unfortunately, the data structure used for the list of players supports only one operation, which
moves a player from position
This operation takes
Determine a sequence of moves to create the ranklist such that the sum of the costs of the moves is minimized.
Input Specification
The first line contains
Output Specification
In the first line of the output print the
number of moves used to create the ranklist. The following lines should specify the moves in the
order in which they are applied. Each move should be described by a line containing two integers
Sample Input
5
20
30
5
15
10
Sample Output
2
2 1
3 5
Grading
30% of the test cases have values of
Comments