No.3704 Awkward Pairs
Problem Statement
$2N$ people of various ages attended a party hosted by the mean-spirited Suken. The $i$-th participant is numbered $i$ and is $A_i$ years old.
The $2N$ people are now to be divided into a total of $N$ pairs of $2$ people each. Here, the awkwardness of a pair is the absolute value of the difference between the ages of its $2$ people.
Find the maximum possible value of the sum of the awkwardness over all pairs. Also, output one example of such a pairing. See Output for the output format.
Input
$N$
$A_1\ A_2\ \cdots\ A_{2N}$
Constraints
- $1 \le N \le 2\times 10^5$.
- $1 \le A_i \le 10^9$.
- All inputs are integers.
Partial Score
This problem has partial scoring based on subtasks.
| Subtask | Score | Constraints |
|---|---|---|
| 小課題1 | 40% (60 pts) | $i=1,2,\cdots, 2N-1$ について, $A_i \le A_{i+1}$ |
| 小課題2 | 60% (90 pts) | 追加の制約はない. |
Output
Output $N+1$ lines. On line $1$, output the maximum awkwardness, and on line $i+1$, output the numbers of the people in the $i$-th pair, separated by a space.
Any output satisfying the conditions will be judged as correct.
Do not output anything other than the answer. (Do not output text such as prompts for input either.)
Sample
Sample 1
Input
3 1 3 4 5 6 8
Output
11 1 6 4 3 2 5
Other outputs, such as $(5, 2), (1, 6), (3, 4)$, are also correct.
This sample input satisfies the constraints of all subtasks.
Sample 2
Input
1 1 1
Output
0 1 2
This sample input satisfies the constraints of all subtasks.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。