457. Two City Scheduling
MediumGreedySorting
2k people will be flown to city A or B; person i costs a_i or b_i. Exactly k go to each city. Print the minimum total cost.
Input format
Line 1: n (= 2k) Next n lines: a b
Output format
The minimum cost.
Example 1
Input
4 10 20 30 200 400 50 30 20
Output
110
Example 2
Input
6 259 770 448 54 926 667 184 139 840 118 577 469
Output
1859
Constraints
2 ≤ n ≤ 100
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…