#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. xampp 安装以及相关问题

    1.安装xampp   说明:xampp集成了mysql,Apache,php,360软件里面就有 2.mysql端口被占用.              如果电脑上已安装MySql数据库,还想用XAM ...

  2. linux下安装mysql-5.6.41

    1.下载安装包,下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads .选择完版本,然后点击下方 No thanks, just ...

  3. LeetCode(67):二进制求和

    Easy! 题目描述: 给定两个二进制字符串,返回它们的和(用二进制表示). 输入为非空字符串且只包含数字 1 和 0. 示例 1: 输入: a = "11", b = " ...

  4. 【sqli-labs】Less11~Less16

    学习sqli-labs的笔记,前面的笔记内容比较详细.后面的只记录关键点了. Less11: POST注入, 有回显,有错误提示 从11题起是POST注入,发现有两个输入框.用firefox的F12查 ...

  5. jdk的卸载及安装+环境变量的配置

    一.卸载:在控制面板中删除.这是最基本的方式.2. 采用360安全卫士的软件卸载工具,记得将有关的注册表信息全部删除.3. 在“运行”中输入Regedit,打开注册表编辑器,找到HKEY_LOCAL_ ...

  6. Lottie 动画

    #### 三方框架之Lotti使用Lottie 的使用 1.添加 Gradle 依赖 dependencies { compile 'com.airbnb.android:lottie:1.5.3'} ...

  7. asp.net core 图片验证码,后台验证

    验证方法: public static string VerificationCodeCacheFormat="vcode_cache_{0}"; public IActionRe ...

  8. js中的原型

    一:原型属性 函数本身也是一个包含了方法和属性的对象. 定义一个函数foo(),访问其他对象一样访问该函数的属性: function foo(a, b) { return a * b; } foo.l ...

  9. iptables命令

    iptables命令是Linux上常用的防火墙软件,是netfilter项目的一部分.可以直接配置,也可以通过许多前端和图形界面配置. 语法 iptables(选项)(参数) 选项 -t<表&g ...

  10. C# 多线程下 静态类字段异常