#P11058. 合并香蕉
合并香蕉
Background

Problem Description
There are bananas. The -th banana can be simplified as a positive integer pair , where .
Initially, there are piles of bananas, and the -th pile contains only the -th banana.
Each time, you may choose two different piles to merge. During a merge, the sizes of bananas will be reduced.
Specifically, if the -th banana participates in a merge, then its size becomes of its original value.
Participates in a merge: before merging, it is in one of the two piles being merged.
You want to merge all bananas into one pile. Since bigger bananas are better, you need to make the sum of all after all operations as large as possible.
Considering that finding the optimal solution may be difficult, you only need to get as close to the standard answer as possible. See the Scoring section for details.
To prevent you from outputting a random number, you also need to output a plan. See the Output Format section for details.
Input Format
The first line contains one positive integer .
The next lines each contain two positive integers .
Output Format
Output lines. Each line contains two numbers , meaning to merge pile and pile .
For the -th merge, denote the newly formed pile as pile . The two original piles (pile and pile ) will henceforth be considered nonexistent, so you are not allowed to use and in later merges. Otherwise, you will get zero points.
3
1 10
27 3
32 2
1 2
4 3
Hint
Sample Explanation
For the sample, the given output corresponds to ending with , and the sum of is .
Also, if you output the following, then it ends with , and the sum of is , which can get points.
1 3
2 4
Scoring
For each test point, scoring is done as follows:
- If your output is invalid, you get points.
- Otherwise, let be the sum of after all operations for your output plan, and let be the sum of after all operations for the standard answer’s plan. Your score is $s=\lfloor \max\{0,10-\log_{10} \max\{1,\frac{ans-f}{\epsilon}\}\}\rfloor$ points, where .
Constraints
This problem has test points, each worth points.
| Test Point ID | Special Property | |
|---|---|---|
| None | ||
| and | ||
| None |
For all data, it is guaranteed that , , and .
Translated by ChatGPT 5