当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
webSocket教程
2022河南萌新联赛第(五)场:信息工程大学 F - 分割草坪
Myunity框架笔记
2022河南萌新联赛第(五)场:信息工程大学 C - 丢手绢
R language cluster analysis - code analysis
Teach you to change the kernel source code--sysfs virtual file system 1
强化学习_11_Datawhale模仿学习
2022河南萌新联赛第(五)场:信息工程大学 B - 交通改造
手机与雷电模拟器里如何使用YiLu代理?
Unity plug-in DOTween User Guide 2 (Brief explanation of Bezier curves)
COLMAP+OpenMVS实现物体三维重建mesh模型
Myunity框架笔记3
Win32屏幕坐标转换Qt坐标
Using parseInt() in TypeScript
UnityShader入门精要-立方体纹理、反射、折射、菲涅尔反射
UnityShader入门精要--Unity中的基础光照
如何在VMlogin中设置YiLu代理?
Talking about 3 common shadow rendering techniques in games (2): shadow cone
Qt中输入框在Win10上“Win+/“快捷键的一个Bug
什么是代理ip?市面上好用的代理软件有哪些









