HSBCOA #1
Arrange Flower Sticks
估计简单可在线判题
考点(AI 标注)原地数组
Sort the first K flower sticks (in input order) by length ascending, sort the remaining sticks by length descending, then concatenate the two parts. The 11 in the statement's example output does not match the input values; under the explicit rule it should be 5.
This site adds n and the value ranges, and fixes obvious typos in the example.
输入格式
The first line contains n (0≤n≤200000); the second line contains n integers; the third line contains K (0≤K≤n). Length values are 32-bit signed integers.
输出格式
Output the n lengths after concatenation according to the rule.
样例 1
输入:
8
17 7 5 10 46 23 16 8
3
输出:
5 7 17 46 23 16 10 8
样例 2
输入:
3
4 4 1
1
输出:
4 4 1
样例 3
输入:
11
14 1 1 20 26 5 18 30 4 3 29
8
输出:
1 1 5 14 18 20 26 30 29 4 3