This page is still under construction.

Parts of this page are still being built. What you see may change.

Process Consultant Seok

Time limit1sMemory limit512 MB

Summary
Gifts are assigned in order to the currently least loaded of K lines; find the smallest K so the maximum line load is at most X.
Level

Medium7 of 10

Topics
Greedy, Binary search, Implementation, Simulation
Solved
No attempts yet

Problem

After a string of successful startups, CEO Ryu Jinguk has decided to build a factory that produces custom gifts. There are currently NN custom gift orders, and each custom gift has a fixed production time. The orders are numbered from 11 to NN, and the production follows these rules.

  1. If there are KK production lines in total, they are numbered from 11 to KK.
  2. The usage time of a production line is the sum of the production times of the custom gifts assigned to it.
  3. Gift ii is assigned, after gifts 11 through i−1i-1 have been assigned, to one of the production lines with the smallest usage time.

At most XX hours remain until all custom gifts must be finished, but the number of production lines KK has not been decided yet. CEO Ryu Jinguk asked the top authority in the field, Process Consultant Seok, for help. Process Consultant Seok wants to minimize the number of production lines in order to spend as little as possible. Help Seok compute the minimum number of production lines needed.

Input

The first line gives the number of custom gift orders NN and the time remaining until production must finish XX, separated by a space.

The second line gives the production time needed for gifts 11 through NN, in order. The unit is 'hour'.

Output

Print the minimum number of production lines needed to produce all gifts within XX hours.

Constraints

  • 1≤N≤100,0001 \le N \le 100,000, NN is a natural number.
  • 1≤X≤1091 \le X \le 10^9, XX is a natural number.
  • 1≤1 \le the production time of each gift ≤X\le X, and every time is a natural number.

Examples1

  1. Example 1

    Input
    6 11
    5 2 8 4 3 5
    
    Expected output
    3