279B.md (1618B)
1 Source: https://codeforces.com/problemset/problem/279/B 2 3 B. Books 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 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. 22 23 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. 24 25 Print the maximum number of books Valera can read. 26 27 Input 28 29 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. 30 31 Output 32 33 Print a single integer — the maximum number of books Valera can read. 34 35 Examples 36 37 Input 38 39 ``` 40 4 5 41 3 1 2 1 42 ``` 43 44 Output 45 46 ``` 47 3 48 ``` 49 50 Input 51 52 ``` 53 3 3 54 2 2 3 55 ``` 56 57 Output 58 59 ``` 60 1 61 ```