#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. LeetCode(84): 柱状图中最大的矩形

    Hard! 题目描述: 给定 n 个非负整数,用来表示柱状图中各个柱子的高度.每个柱子彼此相邻,且宽度为 1 . 求在该柱状图中,能够勾勒出来的矩形的最大面积. 以上是柱状图的示例,其中每个柱子的宽度 ...

  2. 【sqli-labs】Less17

    Less17: POST注入,UPDATE语句,有错误回显 新知识点: 1. update注入方法 参考:http://www.mamicode.com/info-detail-1665678.htm ...

  3. Winhex数据恢复学习笔记(四)

    睡不着,那就深夜写篇笔记打发一下不瞌睡,❥(^_-) 1.winhex在文件批量处理上主要是针对批量保存.打开.关闭,主要还是基于批量打开的其他一些操作,这里通过构造通配符来批量打开,列如 *符号 ? ...

  4. 三维拓扑排序好题hdu3231

    /* 三维拓扑排序 将每个长方体分解成六个面,xyz三维进行操作 每一维上的的所有长方体的面都应该服从拓扑关系,即能够完成拓扑排序=如果两个长方体的关系时相交,那么其对应的三对面只要交叉即可 如 a1 ...

  5. python进行进制转换

    # 10进制转为2进制 print(bin(10)) # 结果:0b1010 # 2进制转为10进制 print(int("1001", 2)) # 结果:9 # 10进制转为16 ...

  6. shell 批量替换内容

    一.查找/data/www/vhosts/WOStest2_YiiFramework/console/sh/下所有.sh文件 把/data/www/vhosts/WOS_YiiFramework 替换 ...

  7. python修改hosts

    #coding=utf-8 host = ['192.168.10.240 store.wondershare.com', '192.168.10.240 store.wondershare.jp', ...

  8. 滴水穿石-04Eclipse中常用的快捷键

    一:常用快捷键 1:内容辅助键  :Alt+/ :main + 该快捷键 :自动生成main方法 :syso + 该快捷键 :自动生成System.out.println();语句 :提示作用 :内容 ...

  9. azkaban group分组,权限

    翻译自:https://azkaban.readthedocs.io/en/latest/userManager.html?highlight=group 1.job project,名为" ...

  10. python 0007

    #coding='utf-8'# import re import os def get_list(): list_file=[] for f in os.listdir(): if f.endswi ...