当前位置:网站首页>2022 Henan Mengxin League No. 5: University of Information Engineering J-AC Automata
2022 Henan Mengxin League No. 5: University of Information Engineering J-AC Automata
2022-08-10 06:32:00 【WA_Automata】
J - AC自动机
P4343 [SHOI2015]自动刷题机
bisecting the left and right endpoints,验证答案,The meaning of the title is not very clear,As a result, it has not been written
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100010;
int a[N];
LL n,k;
int check(LL mid)
{
LL res=0,sum=0;
for(int i=1;i<=n;i++)
{
sum+=a[i];
if(sum<0) sum=0;
if(sum>=mid) res++,sum=0;
}
return res;
}
signed main()
{
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a[i];
LL l,r;
l=1,r=1e18;
while(l<r)
{
LL mid=l+r>>1;
if(check(mid)<=k) r=mid;
else l=mid+1;
}
if(check(r)!=k)
{
cout<<"-1";
return 0;
}
cout<<l<<" ";
l=1,r=1e18;
while(l<r)
{
LL mid=l+r+1>>1;
if(check(mid)>=k) l=mid;
else r=mid-1;
}
cout<<l;
return 0;
}
边栏推荐
猜你喜欢
随机推荐
Unity的GetComponentsInChildren1、2、3
Why need to hot update game?
手把手教你改内核源码--sysfs虚拟文件系统2
QScroller的QScrollerProperties参数研究
求职
共享静态IP与独享静态ip有何区别
BUUCTF笔记(web)
全网可达并设备加密
什么是MQTT网关?与传统DTU有哪些区别?
UnityShader入门精要-高级光照基础
Using parseInt() in TypeScript
新手使用 go channel 需要注意的问题
ArgumentException: GetComponent requires that the requested component ‘GameObject‘ derives from Mono
H3C文档NAT专题
机器学习_LGB调参汇总(开箱即食)
Unity瓦片地图取消部分刚体效果
Myunity框架笔记
vsnprint和snprintf的区别
How to implement a grid construction system
2022河南萌新联赛第(五)场:信息工程大学 F - 分割草坪