Question: 0

0 <= len(arr) <= 10^5

0 <= arr[i] <= 10^5

The array may have duplicate numbers.

Input First line consists of an array of integers denoting the weights of bananas in the godown.

Second line consists of a single integer k which denotes the maximum weight limit of the vehicle in tons.

Output Print the minimum number of vehicles needed.

Time Limit (secs) 1

Examples Example 1

Input

4 2 8 5 1 3 6

8

Output

4

Explanation

We can load (8), (4,3), (6,2), (5, 1) in 4 different vehicles. Any other arrangements will never give less than 4 vehicles.

Example 2

Input

4 7 9 11 6 8 3

12

Output

5

Explanation

We can load (11), (8,3), (6,4), (9), (7) in 5 different vehicles. Any other arrangements will never give less than 5 vehicles.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!