#BS0000313. Sân khấu biểu diễn (Cow Dance Show)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Sân khấu biểu diễn (Cow Dance Show)
Cow Dance Show
Source: USACO
Version: Phuoc Hung OJ Extended
Problem Statement
The farm’s cows are preparing a dance show. The cows are numbered from to in the order in which they must begin their routines. Cow performs for units of time.
A stage of capacity allows at most cows to perform simultaneously. At time , cows through begin. Whenever a cow finishes and leaves the stage, the next waiting cow in order immediately starts if any remain. Several cows may start simultaneously if several slots become free.
The show ends when the last cow finishes. Given a deadline , find the smallest capacity that lets the show end no later than that deadline. Capacity is guaranteed to be feasible.
Input
- The first line contains two integers , the number of cows and the deadline.
- Each of the next lines contains one integer , the duration of cow ’s routine.
Output
Print one integer, the minimum feasible stage capacity.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input 1
5 8
4
7
8
6
4
Output 1
4
Explanation
With four slots, initial finish times are 4,7,8,6; cow 5 finishes at 8. With three slots cow 4 finishes at 10.