Type: RemoteJudge 1000ms 125MiB

序列排序

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

小 C 有一个 NN 个数的整数序列,这个序列的中的数两两不同。

小 C 每次可以交换序列中的任意两个数,代价为这两个数之和。

小 C 希望将整个序列升序排序,问小 C 需要的最小代价是多少?

输入格式

第一行,一个整数 NN

第二行,NN 个整数,表示小 C 的序列。

输出格式

一行,一个整数,表示小 C 需要的最小代价。

6
8 4 5 3 2 7
34

提示

对于 30%30\% 的数据,N10N\le10

对于 100%100\% 的数据,1N1051\le N\le10^5,第二行的 NN 个整数均为不超过 10910^9 的正整数。

1108

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
8
Start at
2025-11-8 14:00
End at
2025-11-8 17:30
Duration
3.5 hour(s)
Host
Partic.
64