10344 - “破锣摇滚”乐队

你刚刚继承了流行的“破锣摇滚”乐队录制的尚未发表的N(1 <= N <= 20)首歌的版权。你打算从中精选一些歌曲,发行M(1 <= M <= 20)张CD。每一张CD最多可以容纳T(1 <= T <= 20)分钟的音乐,一首歌不能分装在两张CD中。

不巧你是一位古典音乐迷,不懂如何判定这些歌的艺术价值。于是你决定根据以下标准进行选择:

歌曲必须按照创作的时间顺序在CD盘上出现。 选中的歌曲数目尽可能地多。

输入

第一行: 三个整数:N, T, M.
第二行: N个整数,分别表示每首歌的长度,按创作时间顺序排列。

输出

一个整数,表示可以装进M张CD盘的乐曲的最大数目。

样例

输入

4 5 2
4 3 4 2

输出

3

提示

Raucous Rockers

You just inherited the rights to N (1 <= N <= 20) previously unreleased songs recorded by the popular group Raucous Rockers. You plan to release a set of M (1 <= M <= 20) compact disks with a selection of these songs. Each disk can hold a maximum of T (1 <= T <= 20) minutes of music, and a song can not overlap from one disk to another.

Since you are a classical music fan and have no way to judge the artistic merits of these songs, you decide on the following criteria for making the selection:

The songs on the set of disks must appear in the order of the dates that they were written. The total number of songs included will be maximized. PROGRAM NAME: rockers INPUT FORMAT Line 1: Three integers: N, T, and M.
Line 2: N integers that are the lengths of the songs ordered by the date they were written.

SAMPLE INPUT (file rockers.in) 4 5 2 4 3 4 2

OUTPUT FORMAT A single line with an integer that is the number of songs that will fit on M disks. SAMPLE OUTPUT (file rockers.out) 3

时间限制 1 秒
内存限制 128 MB
讨论 统计
上一题 下一题