POJ 1700 F(Contest #3)
Description
Input
Output
Sample Input
1
4
1 2 5 10
Sample Output
17
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
freopen("in.txt","r",stdin);
int speed[1000];
int t,n,time;
cin>>t;
int i,j;
for(i=0;i<t;i++)
{
cin>>n;
memset(speed,0,sizeof(speed));
for(j=0;j<n;j++)cin>>speed[j];
sort(speed,speed+n); //从小到大排序
time=0;
while(n>3)
{
if(speed[1]*2 > speed[0]+speed[n-2])
time=time+speed[0]+speed[0]+speed[n-1]+speed[n-2];
else time=time+speed[1]+speed[0]+speed[n-1]+speed[1];
n=n-2;
}
if(n==3)
time=time+speed[0]+speed[1]+speed[2];
else if(n==2)
time=time+speed[1];
else if(n==1)
time=time+speed[0];
cout<<time<<endl;
}
return 0;
}
POJ 1700 F(Contest #3)的更多相关文章
- poj 2187 Beauty Contest(凸包求解多节点的之间的最大距离)
/* poj 2187 Beauty Contest 凸包:寻找每两点之间距离的最大值 这个最大值一定是在凸包的边缘上的! 求凸包的算法: Andrew算法! */ #include<iostr ...
- POJ 3660 Cow Contest / HUST 1037 Cow Contest / HRBUST 1018 Cow Contest(图论,传递闭包)
POJ 3660 Cow Contest / HUST 1037 Cow Contest / HRBUST 1018 Cow Contest(图论,传递闭包) Description N (1 ≤ N ...
- POJ 1719 Shooting Contest(二分图匹配)
POJ 1719 Shooting Contest id=1719" target="_blank" style="">题目链接 题意:给定一个 ...
- POJ 2187 Beauty Contest【凸包周长】
题目: http://poj.org/problem?id=1113 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...
- POJ - 3660 Cow Contest 传递闭包floyed算法
Cow Contest POJ - 3660 :http://poj.org/problem?id=3660 参考:https://www.cnblogs.com/kuangbin/p/31408 ...
- poj 1700
http://poj.org/problem?id=1700 题目大意就是一条船,有N个人需要过河,求N个人最短过河的时间 #include <stdio.h> int main() { ...
- poj 2187 Beauty Contest (凸包暴力求最远点对+旋转卡壳)
链接:http://poj.org/problem?id=2187 Description Bessie, Farmer John's prize cow, has just won first pl ...
- POJ 3660 Cow Contest
题目链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
- poj 1719 Shooting Contest
http://poj.org/problem?id=1719 Shooting Contest Time Limit: 1000MS Memory Limit: 10000K Total Subm ...
随机推荐
- C++——友元、异常和其他
一.友元 类并非只能拥有友元函数,也可以将类作为友元.在这种情况下,友元类的所有方法都可以访问原始类的私有成员和保护成员.另外,也可以做更严格的限制,只将特定的成员函数指定为另一个类的友元.哪些函数. ...
- js 高程(三)学习感言(随时更新)
1.读第二遍了,感觉第一遍白读了. 2.现在还处于初学...
- PHP 用文件流方式展示图片
public function index(){ $img = 'http://img.pf.loc/static/images/2016/05/24/21d98edf98bd6c30afe1c838 ...
- 项目中的五级地址联动效果(js)
我刚开始是的时候是是写了一个sql语句,但是写了5个函数,来联动地址的.后来请教了前段的师傅,用js来写了一个地址联动的. 我使用的是easyui的框架! 地址联动部分html代码! <tr&g ...
- C#_数据库连接串的配置
数据库的连接串 数据库连接字符串的拼写规则的决定条件: 连接的数据库的类型:SQL Server,Oracle,MySQL,Acess,MogoDB,Visual FoxPro(dBASE),Exce ...
- Winform_ComBox三种赋值方式
第一种方法: DataTable dt = new DataTable(); dt.Columns.Add( "name" ); dt.Columns.Add( "val ...
- spring源码深度解析-2功能扩展
容器功能的扩展ApplicationContext用于扩展BeanFactory中现有的功能.究竟多出了哪些功能,进一步探索.写法上:BeanFactory bf = new XmlBeanFacto ...
- return 还是 不return
jQuery.fn.functiona = function() { //return this.each(function() { **** } jQuery(this).css('backgrou ...
- java 基础(第一天)
1. 一个文件里面只能有一个 public 修饰的方法 且方法名与文件名保持一致. 如: public class main(){ } class car(){ } class dog(){ } ...
- 【BZOJ 3295】动态逆序对 - 分块+树状数组
题目描述 给定一个1~n的序列,然后m次删除元素,每次删除之前询问逆序对的个数. 分析:分块+树状数组 (PS:本题的CDQ分治解法见下一篇) 首先将序列分成T块,每一块开一个树状数组,并且先把最初的 ...