This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,A,B;
cin>>n>>A>>B;
int ans=0;
int a[n],pre[n+1]={};
for (int i=0;i<n;i++)
cin>>a[i],pre[i+1]=pre[i]+a[i];
for (int p=30;p>=0;p--)
{
int lim=ans+(1<<p),i=0,seg=0;
bool b=1;
while (i<n && b)
{
int x=lower_bound(pre,pre+n+1,pre[i]+lim)-pre;
int y=lower_bound(pre,pre+n+1,pre[i]+ans)-pre;
if (x==y or x==i+1)
b=0;
seg++;
i=x-1;
}
if (!(b && seg<=B))
ans+=(1<<p);
}
cout<<ans<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |