Problem Statement: You have some boxes and the weights of these boxes are given in an integer array A of size N. You are required to transport all these boxes using K available trucks.
All the boxes must be loaded onto the trucks, using the minimum possible capacity of each truck, in order to be transported. You have to ensure that the total weight of the boxes in each truck does not exceed the integer X, which represents the truck's maximum capacity.
Your task is to find and return an integer value representing the highest value of weights in the truck after optimally placing the boxes into each of the trucks while using each truck's minimum capacity. If transporting all the boxes is not possible, return -1.
Note: * You must load the boxes into the truck in the order they appear, i.e., only adjacent boxes can be loaded into a truck.
Input Specification:
Output Specification:
Example 1:
Problem Statement: Consider the positive X-Axis as a straight road on which N houses are located. On a rainy day, M people are out on a walk. When the rain starts, each person runs towards the nearest house to them, so that they do not get wet. You are given the position of each house, the width of each house and the position of each person when the rain started, in separate integer arrays.
Your task is to find and return an integer value representing the sum of the distances travelled by all the people to reach the house nearest to them.
Note:
Input Specification:
Output Specification: