← 返回 amazon 的题目列表Roller Coaster Ride Problem
类型:online_judge
amazon
Design a program to simulate the transportation process of a roller coaster. The roller coaster has a fixed carriage capacity. In each run, select a subset of passengers to maximize seat utilization. Input consists of the number of passengers and the weight of each passenger. Output the total weight and number of passengers that maximize the load use.
Input:
The first line contains two integers n (1 <= n <= 10^5) and c (1 <= c <= 10^5)
The second line contains n integers representing the weight of each passenger.
Output:
An integer representing the total weight of the passenger combination that maximizes the load.
Example:
Input: 5 20 4 8 5 3 10
Output: 20
Example
Input
5 20
4 8 5 3 10