영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
Problem
A ferry is being loaded with cars, and there's a long line of cars queued up to enter the ferry. Since the time between the ferry's departures is very long, it's important that as many cars as possible can board the ferry. The shipping company, Crappy Shippers Inc., has lately recieved a large number of complaints from the organization Angry Young Algorithmicists, stating that the packing of the cars on the ferry is “bad”, “suboptimal”, “heuristical” and “unsustainable”. The CEO of the company, Ernst. I. S. Crappy confirms that they have been sloppy about packing the ferry, and has just made a statement that they will always pack the ferry with as many cars as possible. Ernst said nothing about how they will do this, but there's a rumor floating around that they have requested the assistance of the Swedish Olympiad in Informatics.
The ferry has four lanes, where each lane is a fixed length which is the same for all the lanes. A line of cars are waiting in a queue to board the ferry, and they will board it in their queuing order. The staff of the shipping company can decide what lane a car should enter (if it fits). When a car can't fit in any of the lanes, the ferry is considered full (this means that no car in the queue is ever skipped, even if a later car could fit in some lane). It's also important that there's a one meter safety margin between cars adjacent in the same lane.
Given the length of the ferry and the lengths of the cars in the queue, help the staff compute the maximum number of cars that can board the ferry.
(그림은 원문 저장소에서 볼 수 있습니다)
Figure 1: An example of an optimal packing of the ferry. The ferry is 5 meters long, and the lengths of the cars in the queue are 2, 1, 2, 5, 1, 1, 2, 1, 1, 2, of which only the first 8 could fit the ferry.
Input
The first line contains the integer N (N ≤ 200), the number of cars. The second line contains the integer L (L ≤ 60), the length of the lanes. This is followed by N integers on a line, where each integer is the length of a car in the same order that they're queuing in. Each car is between 1 and 10 meters long, and does not exceed the length of the ferry.
Output
Output a single integer: the maximum number of cars that can board the ferry.
Points
Your solution will be tested on several test case groups. To get the points for a group, it must pass all the test cases in the group.
| Group | Point value | Constraints |
|---|---|---|
| 1 | 40 | N ≤ 20, L ≤ 40 |
| 2 | 60 | No additional constraints. |
예제
예제 1
10 5 2 1 2 5 1 1 2 1 1 2
8
예제 2
6 1 1 1 1 1 1 1
4
예제 3
10 10 1 2 7 2 5 9 10 9 4 3
7