#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[];
int min(int x, int y)
{
return x < y ? x : y;
}
int main()
{
int t, n;
cin >> t;
while (t--)
{
cin >> n;
for (int i = ; i < n; ++i)
cin >> a[i];
sort(a, a + n);
int ans = , ant = n - ;
while (ant >= )
{
if ( ant == ) ans += a[];
else if (ant == ) ans += a[];
else if (ant == ) ans += a[] + a[] + a[];
else ans += min( * a[] + a[ant] + a[ant - ], * a[] + a[] + a[ant]);
if (ant > ) ant -= ;//大于3个时,2组两组进行
else break;
}
cout << ans << endl;
}
return ;
}

POJ1700----Crossing River的更多相关文章

  1. poj-1700 crossing river(贪心题)

    题目描述: A group of N people wishes to go across a river with only one boat, which can at most carry tw ...

  2. Crossing River

    Crossing River 题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=26251 题意: N个人希望去过 ...

  3. POJ 1700 Crossing River (贪心)

    Crossing River Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9585 Accepted: 3622 Descri ...

  4. Crossing River(1700poj)

    Crossing River Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9919   Accepted: 3752 De ...

  5. poj 1700 Crossing River 过河问题。贪心

    Crossing River Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9887   Accepted: 3737 De ...

  6. poj1700--贪心--Crossing River

    Crossing River Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12260   Accepted: 4641 D ...

  7. POJ1700:Crossing River(过河问题)

    POJ1700 题目链接:http://poj.org/problem?id=1700 Time Limit:1000MS     Memory Limit:10000KB     64bit IO ...

  8. Crossing River poj1700贪心

    题目描述:N个人过河,只有一只船,最多只能有两人划船,每个人划船速度不同,船速为最慢的人的速度.输入T为case个数,每个case输入N为人数,接下来一行输入的是每个人过河的时间,都不相同.要求输出N ...

  9. POJ-1700 Crossing River---过河问题(贪心)

    题目链接: https://vjudge.net/problem/POJ-1700 题目大意: 有N个人要渡河,但是只有一艘船,船上每次最多只能载两个人,渡河的速度由两个人中较慢的那个决定,小船来回载 ...

  10. I - Crossing River

    A group of N people wishes to go across a river with only one boat, which can at most carry two pers ...

随机推荐

  1. 课外知识----base64加密

    每3个字符产生4位的base64字符,不足3个字符,将用“=”补齐至4位base64字符 例如 00--->  MDA= 000--->MDAw base64加密特点 加密后的字符数是4的 ...

  2. Nginx详解二十二:Nginx深度学习篇之Lua解释器安装及基础语法

    解释器 Lua:Lua是一个简洁.轻量.可扩展的脚本语言 Nginx+Lua优势充分的结合Nginx的并发处理epoll优势的Lua的轻量实现简单的功能切高并发的场景 安装Lua 1.安装解释器:yu ...

  3. python基础面试题(一)

    1.   简述Python代码的运行机制 1.把原始代码编译成字节码         编译后的字节码是特定于Python的一种表现形式,它不是二进制的机器码,需要进一步编译才能被机器执行. 2.把编译 ...

  4. Spring Cloud与Spring Boot版本匹配关系

    Spring Cloud是什么? “Spring Cloud provides tools for developers to quickly build some of the common pat ...

  5. C++ ifstream ofstream

    原文出自[比特网],转载请保留原文链接:http://soft.chinabyte.com/database/460/11433960.sh [导读] ofstream是从内存到硬盘,ifstream ...

  6. [转] 对Array.prototype.slice.call()方法的理解

    在看别人代码时,发现有这么个写法:[].slice.call(arguments, 0),这到底是什么意思呢? 1.基础 1)slice() 方法可从已有的数组中返回选定的元素. start:必需.规 ...

  7. fputcsv导出大量数据

    <?php set_time_limit(0); ini_set('memory_limit', '128M'); $fileName = date('YmdHis', time()); hea ...

  8. 最长k可重区间集问题&&最长k可重线段集问题

    题解: 洛谷上这两题的题意都是有问题的 按照标程题意不应该是开区间而是左开右闭区间 然后连边比较巧妙 我们可以看成选k条不相交的路径,其中i-i+1中有k条边 所以建图i-i+1流量为k,权值为0 l ...

  9. Python_socket

    TCP : 可靠传输,不安全,UDP: 安全传输,不可靠 一台机器上有2^16-1=65535个端口(1-1024)保留自己开就1024往上 socket (套接字):也可以理解为它是一个管道,用于描 ...

  10. Python_set集合部分功能介绍

    set:无序集合,不能出现重复的元素 set的创建:s1=set() #访问速度快 #解决重复问题 x.add():添加一个新的元素,添加的重复的元素自动过滤掉 x.clear():清空集合 x.di ...