#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 |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |