#P5626. 【AFOI-19】数码排序
【AFOI-19】数码排序
Description
While escaping, some “digits” also escaped. They kept making noise and asked Little L to help sort them.
The digits in the virtual world are invisible.
Little L currently only knows selection sort, insertion sort, bubble sort, and merge sort.
So Little L wants to ask: in the worst case, what is the minimum number of comparisons needed to make the sequence sorted?
Input Format
There is only one line of input: a positive integer , representing the length of the sequence.
Output Format
Output the minimum number of comparisons.
4
5
5
8
Hint
- Sample Explanation
For a sequence of length , merge sort splits it into groups, with elements in each group. The elements in each group are compared once. During merging, the worst case needs comparisons, so the total is .
- Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
The testdata is guaranteed to be random.
Translated by ChatGPT 5
京公网安备 11011102002149号