我是靠谱客的博主 舒服铅笔,最近开发中收集的这篇文章主要介绍Crossing River(翻译),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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人过河所需的总秒数。

最后

以上就是舒服铅笔为你收集整理的Crossing River(翻译)的全部内容,希望文章能够帮你解决Crossing River(翻译)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(71)

评论列表共有 0 条评论

立即
投稿
返回
顶部