【题解】Crossing River】的更多相关文章

Crossing River 题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=26251 题意: N个人希望去过河,但每次只能过两个且要有一个人把船划回来接其他的人: 两个人一起过河所用的时间是两个人中单独过河时间最多的: 求所有人过河所需要的最少的时间. 思路分析: 定义一个装n个人中每个人过河所需要的时间数组a[]:并用sort进行从小到大进行排序. 求将最慢的和次慢的运过去所需的最少时间,下面有两种可能…
Crossing River Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9585 Accepted: 3622 Description 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 arrangem…
Crossing River Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9919   Accepted: 3752 Description 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 arra…
Crossing River Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9887   Accepted: 3737 Description 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 arra…
Crossing River Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12260   Accepted: 4641 Description 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 arr…
题目描述 几个人过河,每次过两人一人回,速度由慢者决定,问过河所需最短时间. 输入格式 输入t组数据,每组数据第1行输入n,第2行输入n个数,表示每个人过河的时间. 输出格式 输出t行数据,每行1个数,表示每组过河最少时间. 输入样例 1 4 1 2 5 10 输出样例 17 题解 容易想到,我们要尽可能利用速度快的人,且尽可能先把慢的人送走. 据此可以想到贪心策略:设$n$个人的时间升序排列为$a_{1}$到$a_{n}$,那么我们就让第$n$个人把第$1$个人运到对岸,再让第$1$个人自己回…
题目链接 题目大意 t组数据(t<=20) 给你n个人(n<=1000)过河,每个人都有权值,一条船,每次船最多运2个人,每次的花费为两个人的较大花费 求所有人都过河需要的最小花费 题目思路 经典的过河问题,记录一下 先将权值从小到大排序一下 每次运两个人显然有两种最优的方法 1:先运(a[1],a[2])过去,a[1]回来,再运(a[n],a[n-1])过去,a[2]回来 cost1=a[n]+2*a[2]+a[1] 2:先运(a[n],a[1])过去,a[1]回来,再运(a[n-1],a[…
POJ1700 题目链接:http://poj.org/problem?id=1700 Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u   Description A group of N people wishes to go across a river with only one boat, which can at most carry two persons. Therefore…
题目描述: 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 pers…
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…