Little Monk and his toy-story
Tag(s):

## Easy-Medium, Greedy, Math

Problem
Editorial
Analytics

Little Monk has N number of toys, where each toy has some width Wi. Little Monk wants to arrange them in a pyramdical way with two simple conditions in his mind. The first being that the total width of the ith row should be less than (i+1)th row. The second being that the total number of toys in the ith row should be less than (i+1)th row. Help Monk find the maximum height which is possible to be attained!

Note: It is NOT necessary to use all the boxes.

Input format:
The first line contains an integer N, which denotes the number of Monk's toys. The next line contains N integers each denoting the width of the Monk's every single toy.

Output format:
Print the maximum height of the toy pyramid.

Constraints:
1N$10^6$
1Ni$10^9$

SAMPLE INPUT
4
40 100 20 30

SAMPLE OUTPUT
2

Explanation

On the lowest level, we can place $20$ and $100$, and on top of it we can place $40$, so the maximum height would be 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++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

CodeMonk (Greedy Technique)

OTHER PROBLEMS OF THIS CHALLENGE
• Algorithms > Greedy Algorithms
• Algorithms > Greedy Algorithms
• Algorithms > Greedy Algorithms
• Math > Basic Math