CF1244G Running in Pairs
题目描述
**题目大意**:
找出两个1到n的全排列p和q,使得
$\sum^n_{i=1} \max(p_i,q_i)$尽量大且不超过给定的k。
输入格式
无
输出格式
无
说明/提示
In the first example the order of runners on the first track should be $ [5, 3, 2, 1, 4] $ , and the order of runners on the second track should be $ [1, 4, 2, 5, 3] $ . Then the duration of the competition is $ max(5, 1) + max(3, 4) + max(2, 2) + max(1, 5) + max(4, 3) = 5 + 4 + 2 + 5 + 4 = 20 $ , so it is equal to the maximum allowed duration.
In the first example the order of runners on the first track should be $ [2, 3, 1] $ , and the order of runners on the second track should be $ [2, 1, 3] $ . Then the duration of the competition is $ 8 $ , and it is the maximum possible duration for $ n = 3 $ .