302393: CF461A. Appleman and Toastman
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Appleman and Toastman
题意翻译
### 问题描述 苹果人和土司人正在玩游戏。一开始苹果人把包含 $n$ 个数的一组数给土司人,然后他们开始进行下面两个步骤: - 每次土司人得到一组数,他把这些数的和加入到得分中,然后他把这组数交给苹果人。 - 每次苹果人得到只包含一个数的一组数,他会把这组数扔掉;每次苹果人得到包含至少两个数的一组数,他会任意的把它分成两个非空的组,并把这两组数分别交给土司人。 在这两个逗逼完成了所有的任务后他们会查看他们的分数。他们的最多能得多少分呢? ### 输入格式 第一行包含一个整数 $n$($1\le n\le 3\times 10^5$)。 第二行包含 $n$ 个整数 $a_1,a_2,\cdots,a_n$($1\le a_i\le 10^6$),表示一开始土司人得到的一组数。 ### 输出格式 输出一个整数,表示可能的最大的分。题目描述
Appleman and Toastman play a game. Initially Appleman gives one group of $ n $ numbers to the Toastman, then they start to complete the following tasks: - Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. Then he gives the group to the Appleman. - Each time Appleman gets a group consisting of a single number, he throws this group out. Each time Appleman gets a group consisting of more than one number, he splits the group into two non-empty groups (he can do it in any way) and gives each of them to Toastman. After guys complete all the tasks they look at the score value. What is the maximum possible value of score they can get?输入输出格式
输入格式
The first line contains a single integer $ n $ ( $ 1<=n<=3·10^{5} $ ). The second line contains $ n $ integers $ a_{1} $ , $ a_{2} $ , ..., $ a_{n} $ ( $ 1<=a_{i}<=10^{6} $ ) — the initial group that is given to Toastman.
输出格式
Print a single integer — the largest possible score.
输入输出样例
输入样例 #1
3
3 1 5
输出样例 #1
26
输入样例 #2
1
10
输出样例 #2
10