Monk and Special Integer
Tag(s):

## Algorithms, Binary Search, Easy-Medium

Problem
Editorial
Analytics

Monk and his best friend Micro were taking a stroll, when they found an array $A$ having $N$ integers lying on the road. The array was injured badly, so they took it with them and treated it.

When the array came back to senses, it told them, that some crazy guy came and started beating it. The array started crying and while Monk and Micro were comforting it, the last element of the array informed that the special integer is missing from its pocket. After hearing that, the array started crying even louder because it is supposed to appear in the next Code Monk Challenge with that Special Integer.

Special integer, $K$, of an array, is an integer such that none of its subarray of size $K$ has sum of elements greater than $X$. To calm the array down, Monk decided to gift it the maximum possible value of special integer $K$. Now since Monk is busy with Code Monk he asked Micro to find the maximum value of special integer but right now, all Micro can think of is a Potato, so Micro asked for your help.

Input Format:
First line consists of two space separated integers denoting $N$ and $X$.
Second line consists of $N$ space separated integers denoting the array $A$.

Output Format:
Print the maximum possible value of special integer.

Constraints:
$1 \le N \le 10^5$
$1\le X \le 10^{18}$
$1 \le A[i] \le min(X, 10^9)$

SAMPLE INPUT
4 8
1 2 3 4


SAMPLE OUTPUT
2

Explanation

Sum of all subarrays of size $1$: $1, 2, 3, 4$
Sum of all subarrays of size $2$: $3, 5, 7$
Sum of all subarrays of size $3$: $6, 9$
Sum of all subarrays of size $4$: $10$
So clearly, maximum subarray size, such that all subarrays of that size have sum of elements less than $8$ is $2$.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala 2.11.8, Swift, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

CodeMonk (Searching)

OTHER PROBLEMS OF THIS CHALLENGE
• Algorithms > Searching
• Algorithms > Searching
• Algorithms > Searching
• Algorithms > Searching
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.15301555395126343, "perplexity": 5524.136750250363}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2017-22/segments/1495463612018.97/warc/CC-MAIN-20170529053338-20170529073338-00160.warc.gz"}