当前位置:网站首页>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;
}
边栏推荐
猜你喜欢
随机推荐
Unity2d自动寻路(AI插件)
Unity扩展编辑器EditorWindow 小玩意(二)
手机与雷电模拟器里如何使用YiLu代理?
Parallax Mapping: More Realistic Texture Detail Representation (Part 1): Why Use Parallax Mapping
手把手教你改内核源码--sysfs虚拟文件系统2
Teach you to change the kernel source code--sysfs virtual file system 2
深入理解数组
虚幻5简单第三人称游戏制作文档
关于研究鼠标绘制平滑曲线的阶段总结
Talking about 3 Common Shadow Rendering Techniques in Games (3): Shadow Mapping
Kernel Image File Format
vsnprint和snprintf的区别
1413. 逐步求和得到正数的最小值
Unity瓦片地图取消部分刚体效果
请问为什么sqlserver cdc,任务启动过了一天,会报这个错误,明明已经开启cdc了。
2022河南萌新联赛第(五)场:信息工程大学 F - 分割草坪
什么是代理ip?市面上好用的代理软件有哪些
2022河南萌新联赛第(五)场:信息工程大学 K - 矩阵生成
几行代码就可以把系统高崩溃;
Myunity框架笔记








