#K33667. Minimum Trips for Package Delivery
Minimum Trips for Package Delivery
Minimum Trips for Package Delivery
You are given a drone with a maximum weight capacity \(C\) and a collection of packages, each with a specific weight. Your task is to determine the minimum number of trips the drone must make to deliver all the packages. In each trip, you can load a subset of packages as long as the total weight does not exceed \(C\). The packages can be delivered in any order.
Input: The first line of input contains two integers \(C\) and \(n\), where \(C\) denotes the maximum weight capacity of the drone and \(n\) is the number of packages. The second line contains \(n\) space-separated integers representing the weights of the packages.
Output: Output a single integer representing the minimum number of trips required to deliver all the packages.
inputFormat
The input is read from stdin and consists of:
- The first line contains two integers \(C\) (the drone's maximum capacity) and \(n\) (the number of packages).
- The second line contains \(n\) space-separated integers, each denoting the weight of a package.
outputFormat
The output should be printed to stdout and is a single integer: the minimum number of trips required to deliver all packages.
## sample10 5
2 3 7 5 6
3