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 ...
随机推荐
- jQuery为div添加select和option
简单描述:用jQuery给页面添加select下拉框,直接上图 总结:清楚明了^_^
- 拓展中国剩余定理(ex_crt)
一般来讲,crt(中国剩余定理)比较常见,而ex_crt(拓展中国剩余定理)不是很常用 但是noi 2018偏偏考了这么个诡异的东西... 所以这里写一个ex_crt模板 模型: 求一个x满足上述方程 ...
- bootstrap-table 刷新页面数据
bom.bootstrapTable('load',msg['object']);//这一步 务必要添加. if(msg['code']==1){ bom.find('tbody').css('dis ...
- 论文阅读笔记三十六:Mask R-CNN(CVPR2017)
论文源址:https://arxiv.org/pdf/1703.06870.pdf 开源代码:https://github.com/matterport/Mask_RCNN 摘要 Mask R-CNN ...
- java基础应用循环的应用
1.1 [经典面试题]: &&(短路与)与&(非短路与)的区别: 表达式1 && 表达式2 表达式1如果为false,表达式2不执行,整个表达式结果为false ...
- python算法
选择排序的实现: #选择排序的实现 def xzpx(arr): for i in range(0,len(arr)): # 每趟排序 k=i for j in range(i+1,len(arr)) ...
- MQ消息队列之MSMQ
主要参考文章: 消息队列(Message Queue)简介及其使用
- functiontools模块
#!/usr/bin/env python# -*- coding:utf-8 -*-from functools import cmp_to_key a = [1, 6, 4, 5]a.sort(k ...
- [转]教你十分钟下载并破解IntelliJ IDEA(2017)
来源:http://www.itwendao.com/article/detail/400687.html 温馨提示:IntelliJ IDEA(2017)需要安装JDK8以上才能运行 如果你是JDK ...
- 【C#】使用OWIN创建Web API
OWIN的介绍 OWIN 的全称是 "Open Web Interface for .NET", OWIN 在 .NET Web 服务器和 .NET Web 应用之间定义了一套标准 ...