POJ1700----Crossing River
#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的更多相关文章
- 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 ...
- Crossing River
Crossing River 题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=26251 题意: N个人希望去过 ...
- POJ 1700 Crossing River (贪心)
Crossing River Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9585 Accepted: 3622 Descri ...
- Crossing River(1700poj)
Crossing River Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9919 Accepted: 3752 De ...
- poj 1700 Crossing River 过河问题。贪心
Crossing River Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9887 Accepted: 3737 De ...
- poj1700--贪心--Crossing River
Crossing River Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12260 Accepted: 4641 D ...
- POJ1700:Crossing River(过河问题)
POJ1700 题目链接:http://poj.org/problem?id=1700 Time Limit:1000MS Memory Limit:10000KB 64bit IO ...
- Crossing River poj1700贪心
题目描述:N个人过河,只有一只船,最多只能有两人划船,每个人划船速度不同,船速为最慢的人的速度.输入T为case个数,每个case输入N为人数,接下来一行输入的是每个人过河的时间,都不相同.要求输出N ...
- POJ-1700 Crossing River---过河问题(贪心)
题目链接: https://vjudge.net/problem/POJ-1700 题目大意: 有N个人要渡河,但是只有一艘船,船上每次最多只能载两个人,渡河的速度由两个人中较慢的那个决定,小船来回载 ...
- 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 ...
随机推荐
- 五.ssh远程管理服务
01. 远程管理服务知识介绍 1) SSH远程登录服务介绍说明 SSH是Secure Shell Protocol的简写,由 IETF 网络工作小组(Network Working Group)制定: ...
- 【es】创建索引和映射
参考:http://www.cnblogs.com/sheeva/p/4837881.html 创建索引: curl -XPUT 'http://localhost:9200/some_index' ...
- AppServ安装到一半卡住的问题
今天在笔记本安装AppServ的时候,运行到Installing mysql service时就卡住不动了,因为之前在自己的台式电脑安装过AppServ,当时是一步成功的,所以觉得这个问题莫名其妙,因 ...
- uva11754 中国剩余定理+暴力搜索
是当y的组合数较小时,暴力枚举所有组合,然后用中国剩余定理求每种组合的解,对解进行排序即可 注意初始解可能是负数,所以如果凑不够S个,就对所有解加上M,2M.... 当y的组合数较大时,选择一个k/x ...
- c++ 链表基础功能实现
#include<stack> struct ListNode { int m_nValue; ListNode* m_pNext; }; ListNode* CreateListNode ...
- ActiveSync 学习记录
协议就是一种规范.它是高效团队协作的依据.有的人可能不爱看团队规范之类的文档,一方面是个人意识问题,另外也和文档的组织.协作的效果相关. 写好文档: 看好文档. 1. 处理XML转码 抓包后,发现邮件 ...
- python的相关基本操作
1.安装第三方库:pip install requests 2.升级:pip install --upgrade library_name 3.升级所有已安装的库: pip list --outdat ...
- Python(列表操作应用实战)方法二
# 输入一个数据,删除一个列表中的所有指定元素# 给定的列表数据data = [1,2,3,4,5,6,7,8,9,0,5,4,3,5,"b","a",&quo ...
- webpack学习笔记--整体配置结构
之前的章节分别讲述了每个配置项的具体含义,但没有描述它们所处的位置和数据结构,下面通过一份代码来描述清楚: const path = require('path'); module.exports = ...
- html5 之 local storage \sessjion storage
转载: HTMl5的sessionStorage和localStorage html5中的Web Storage包括了两种存储方式:sessionStorage和localStorage. sessi ...