Three Slices
InterviewTime limit1sMemory limit1024 MB
Find the largest M such that the array contains three consecutive blocks of length M, each with sum at most K.
- Level
Medium5 of 10
- Topics
- Binary search, Prefix sum, Sliding window
- Solved
- No attempts yet
Statement
You are given an array of positive integers. You are also given a positive integer . Find the largest positive integer such that the following condition holds.
-
There exists an integer such that
Input
The first line contains two integers and . The second line contains the elements of the array in order.
Output
Print the largest positive integer that satisfies the condition. If no such exists, print .