CF279B.Books
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the books by integers from 1 to n. Valera needs a__i minutes to read the i-th book.
Valera decided to choose an arbitrary book with number i and read the books one by one, starting from this book. In other words, he will first read book number i, then book number i + 1, then book number i + 2 and so on. He continues the process until he either runs out of the free time or finishes reading the n-th book. Valera reads each book up to the end, that is, he doesn't start reading the book if he doesn't have enough free time to finish reading it.
Print the maximum number of books Valera can read.
当瓦莱拉有空闲时间时,他会去图书馆读书。今天他有 t 分钟的空闲时间用来阅读。因此,瓦莱拉从图书馆挑选了 n 本书,并对每本书估算了自己所需的阅读时间。我们将这些书依次编号为 1 到 n。瓦莱拉阅读第 i 本书需要 ai 分钟。
瓦莱拉决定任意选定一本编号为 i 的书作为起点,然后从此书开始依次阅读:即先读第 i 本书,再读第 i+1 本书,接着读第 i+2 本书,依此类推。他持续这一过程,直到空闲时间耗尽,或读完第 n 本书为止。瓦莱拉总是将一本书完整读完(即:若剩余空闲时间不足以读完当前书,则他不会开始阅读该书)。
请输出瓦莱拉最多能读完的书本数量。
输入格式
The first line contains two integers n and t (1 ≤ n ≤ 105; 1 ≤ t ≤ 109) — the number of books and the number of free minutes Valera's got. The second line contains a sequence of n integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 104), where number a__i shows the number of minutes that the boy needs to read the i-th book.
第一行包含两个整数 n 和 t(1 ≤ n ≤ 105;1 ≤ t ≤ 109)——分别表示书的总数以及瓦列拉拥有的免费分钟数。
第二行包含一个由 n 个整数 a1, a2, ..., an(1 ≤ ai ≤ 104)组成的序列,其中 ai 表示男孩阅读第 i 本书所需的分钟数。
输出格式
Print a single integer — the maximum number of books Valera can read.
输出一个整数——Valera 最多能读的书本数量。
输入输出样例
输入#1
4 5 3 1 2 1
输出#1
3
输入#2
3 3 2 2 3
输出#2
1
输入解题思路,AI测评打分。不知道怎么写?