第十四届华中科技大学程序设计竞赛 K--Walking in the Forest
链接:https://www.nowcoder.com/acm/contest/106/K
来源:牛客网
题目描述
输入描述:
输出描述:
An integer, the minimum distance of the largest step.
输入例子:
6 3
1 3 2 2 5
输出例子:
5
-->
输入
6 3
1 3 2 2 5
输出
5 题解:
二分答案(好蠢啊)
/*
data:2018.5.22
author:gsw
link:https://www.nowcoder.com/acm/contest/106/K
*/
#define ll long long
#define IO ios::sync_with_stdio(false); #include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005 ll l,r,mid;
int n,k;
ll dis[maxn];
bool judge(ll d)
{
ll tem=;int kk=;
for(int i=;i<n-;i++)
{
if(dis[i]>d)return false;
if(tem+dis[i]>d)
{
tem=dis[i];
kk++;
}
else tem+=dis[i];
}
kk++;
if(kk>k)return false;
return true;
}
int main()
{
l=r=;
scanf("%d%d",&n,&k);
for(int i=;i<n-;i++)
{
scanf("%lld",&dis[i]);
r+=dis[i];
}ll mid=;
while(l<r-)
{
mid=(l+r)>>;
if(judge(mid))r=mid;
else l=mid;
}
printf("%lld\n",r);
return ;
}
第十四届华中科技大学程序设计竞赛 K--Walking in the Forest的更多相关文章
- 第十四届华中科技大学程序设计竞赛 K	Walking in the Forest【二分答案/最小化最大值】
		
链接:https://www.nowcoder.com/acm/contest/106/K 来源:牛客网 题目描述 It's universally acknowledged that there'r ...
 - 第十四届华中科技大学程序设计竞赛 C Professional Manager【并查集删除/虚点】
		
题目描述 It's universally acknowledged that there're innumerable trees in the campus of HUST. Thus a pro ...
 - 第十四届华中科技大学程序设计竞赛决赛同步赛 A - Beauty of Trees
		
A - Beauty of Trees 题意: 链接:https://www.nowcoder.com/acm/contest/119/A来源:牛客网 Beauty of Trees 时间限制:C/C ...
 - 第十四届华中科技大学程序设计竞赛决赛同步赛 F  Beautiful Land(01背包,背包体积超大时)
		
链接:https://www.nowcoder.com/acm/contest/119/F来源:牛客网 Beautiful Land 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1 ...
 - 第十四届华中科技大学程序设计竞赛 J Various Tree【数值型一维BFS/最小步数】
		
链接:https://www.nowcoder.com/acm/contest/106/J 来源:牛客网 题目描述 It's universally acknowledged that there'r ...
 - 第十四届华中科技大学程序设计竞赛 B Beautiful Trees Cutting【组合数学/费马小定理求逆元/快速幂】
		
链接:https://www.nowcoder.com/acm/contest/106/B 来源:牛客网 题目描述 It's universally acknowledged that there'r ...
 - 第十四届华中科技大学程序设计竞赛决赛同步赛    	Beautiful Land
		
It’s universally acknowledged that there’re innumerable trees in the campus of HUST.Now HUST got a b ...
 - 第十四届华中科技大学程序设计竞赛--J	Various Tree
		
链接:https://www.nowcoder.com/acm/contest/106/J来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536 ...
 - Minieye杯第十五届华中科技大学程序设计邀请赛现场同步赛 I 	Matrix Again
		
Minieye杯第十五届华中科技大学程序设计邀请赛现场同步赛 I Matrix Again https://ac.nowcoder.com/acm/contest/700/I 时间限制:C/C++ 1 ...
 
随机推荐
- Delphi RegisterHotKey 设置系统热键
			
Symbolic constant name Value (hexadecimal) Keyboard (or mouse) equivalent VK_LBUTTON 01 Left mouse b ...
 - php中的list()
			
list()在php中上一个语言结构,并不是一个函数.类似array(),不过array()这个东西我们现在一般很少使用了,因为从php5.4版本开始,我们会直接使用[]来定义数组. 那么,list( ...
 - 能打开电脑都看懂的系列之Windows下修改MongoDB用户密码
			
起因 还能怎么滴,我忘了MongoDB的密码呗. 操作 进入MongoDB的安装目录的bin目录下,(我的目录是D:\developer\MongoDB\Server\4.2\bin): 用记事本打开 ...
 - 导入csv 到mysql数据库
			
1.查询导入数据存放位置 show variables like '%secure%'; +--------------------------+-----------------------+ | ...
 - 人物-IT-程维:百科
			
ylbtech-人物-IT-程维:百科 程维,滴滴出行创始人兼CEO,全面负责滴滴公司的战略规划和运营管理. 程维曾在阿里巴巴集团任职八年,于区域运营和支付宝B2C业务上取得成功的管理经验.2012年 ...
 - 仿flask写的web框架
			
某大佬仿flask写的web框架 web_frame.py from werkzeug.local import LocalStack, LocalProxy def get_request_cont ...
 - 20140923 cin.get() getline cin
			
#include<iostream> #include<string> using namespace std; int main() { string title; ...
 - span 设置inline-block 写文字的span错位
			
写一个如下图这样排版 设置几个span为inline-block 中间的span写了文字的span错位了 解决方案 给span添加 vertical-align: top
 - 关于软件IntelliJ IDEA的使用技巧(一)
			
一,IntelliJ IDEA的下载 点击网址http://www.jetbrains.com/idea/进入官网,点击Download 会出现如下页面 点击Ultimate下的Download,下载 ...
 - java web session共享
			
一 搭建环境 操作系统:windows 7 64位 http server:nginx 1.9.7 缓存系统:memcached Servlet容器:apache-tomcat-7.0.65 二 搭建 ...