主页 讨论版 问题 名次 状态 统计

请自觉遵守比赛规则,违者严惩,不接受求情!

问题 E: ship

问题 E: ship

时间限制:1000 ms 内存限制:128 MB
提交:51 解决:29
[ 提交][ 状态][ 讨论版]

题目描述

The members of XDU-ACM group went camp this summer holiday. They came across a river one day. There was a ship which only can carry at most two people at the same time. The ship would move only if there is at least one person in the ship to drive it. Everyone had different cost of time to pass the river, and the time of pass the river by ship depended on the longer time of the two passengers. You should tell them the minimum total time that all of the members should spend to arrive the next band.

输入

The input contains multiple test cases.
The first line of each case contains one integer n (1≤n≤100000). Then next n lines contains n positive integers a[i](1≤a[i]≤10000)-the ith person spend a[i] time to pass the river.

输出

For each case ,print the minimum total time they should spend in the only line.

样例输入

4 2 3 6 11

样例输出

22

提示

[ 提交][ 状态][ 讨论版]
Baidu
map