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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started