当前位置: 首页 > 工具软件 > River Trail > 使用案例 >

Crossing River(翻译)

易骁
2023-12-01

http://noi.openjudge.cn/ch0406/702/

描述

A group of N people wishes to go across a river with only one boat, which can at most carry two persons. Therefore some sort of shuttle arrangement must be arranged in order to row the boat back and forth so that all people may cross. Each person has a different rowing speed; the speed of a couple is determined by the speed of the slower one. Your job is to determine a strategy that minimizes the time for these people to get across.

N个人想用只用一条船过河,这艘船一次最多带俩人。因此要安排一些过河组合来划船以便所有人能过河。每个人有不同的划船速度。一组人的划船速度由速度最慢的人决定。你的任务是决定一个策略来让这些人过河时间最短

输入

The first line of the input contains a single integer T (1 <= T <= 20), the number of test cases. Then T cases follow. The first line of each case contains N, and the second line contains N integers giving the time for each people to cross the river. There won't be more than 1000 people and nobody takes more than 100 seconds to cross.

第一行输入包含一个整数T,测试样例的数量。然后接着T行,每个样例第一行包含一个N,第二行包含N个整数代表每个人过河的时间。不会超过1000人过河并且没人花费超过100秒

输出

For each test case, print a line containing the total number of seconds required for all the N people to cross the river.

对于每个测试用例,打印一行,其中包含所有N人过河所需的总秒数。

 类似资料: