description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def main(): nk = list(map(int, input("").split())) aList = list(map(int, input("").split())) n = nk[0] k = nk[1] sum = 0 count = 0 j = 0 result = 0 for i in range(0, len(aList)): sum = sum + aList[i] while sum > k: sum = sum - aList[j] count -= 1 j += 1 result = max(result, i - j + 1) print(result) main()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = [int(i) for i in input().split()] a = [int(i) for i in input().split()] start = 0 end = 0 sumtime = 0 ans = 0 for i in range(n): sumtime += a[i] end = i + 1 while start < end and sumtime > t: sumtime -= a[start] start += 1 if end - start > ans: ans = end - start print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def mi(): return map(int, input().split()) n, t = mi() a = list(mi()) res = 0 time = 0 count = 0 i, j = 0, 0 while i < len(a) and j < len(a): if time + a[j] <= t: time += a[j] j += 1 count += 1 res = max(count, res) else: time -= a[i] count -= 1 i += 1 print(res)
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = [int(i) for i in input().split()] books = [int(i) for i in input().split()] i = 0 j = 0 count = 0 acum = 0 tmp_acum = 0 tmp_count = 0 while i < n: if tmp_acum + books[i] <= t: tmp_acum += books[i] tmp_count += 1 i += 1 else: count = max(count, tmp_count) tmp_acum = max(tmp_acum - books[j], 0) tmp_count = max(tmp_count - 1, 0) j += 1 i = max(i, j) print(str(max(count, tmp_count)))
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split(" ")) a = list(map(int, input().split(" "))) total_time = 0 count = 0 j = 0 for i in range(n): while j < n and total_time + a[j] <= t: total_time += a[j] j += 1 count = max(count, j - i) total_time -= a[i] if j == n - 1: print(count) exit() print(count)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def ans(a_list, k): length = len(a_list) l_length = 0 longest = 0 s = 0 for i in range(length): while s <= k: longest = max(l_length, longest) if i + l_length == length: return longest s += a_list[i + l_length] l_length += 1 l_length -= 1 s -= a_list[i] return longest a, m = map(int, input().split()) arr = list(map(int, input().split())) print(ans(arr, m))
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR VAR RETURN VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
I = lambda: map(int, input().split()) n, t = I() a = list(I()) i = 0 read = 0 s = 0 k = 0 MAX = -float("inf") while k < n: s += a[k] if s > t: MAX = max(MAX, read) s -= a[i] s -= a[k] i += 1 read -= 1 k -= 1 else: read += 1 k += 1 print(max(read, MAX))
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING WHILE VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) l = list(map(int, input().split())) j, i = 0, 0 c = 0 m = 0 while j < n: if t - l[j] >= 0: t -= l[j] c = j - i + 1 else: t += l[i] c = j - i i += 1 j -= 1 m = max(m, c) j += 1 print(m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
a, b = map(int, input().rstrip().split()) l = list(map(int, input().split())) start, maxi = 0, 0 cur_sum = l[0] for i in range(1, a + 1): while cur_sum > b and start < i - 1: cur_sum = cur_sum - l[start] start += 1 if cur_sum <= b: maxi = max(maxi, i - start) if i < a: cur_sum += l[i] print(maxi)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
from sys import * input = stdin.readline n, k = map(int, input().split()) l = list(map(int, input().split())) c = 0 j = 0 for i in range(n): c = c + l[i] if c > k: c = c - l[j] j = j + 1 print(n - j)
ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
import sys n, t = map(int, input().split()) a = list(map(int, input().split())) tottime = 0 left = 0 cnt = 0 finalcnt = 0 for x in a: tottime += x cnt += 1 while tottime > t: cnt -= 1 tottime -= a[left] left += 1 finalcnt = max(finalcnt, cnt) print(finalcnt)
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, m = list(map(int, input().split())) l = list(map(int, input().split())) maxi = 0 ind = 0 ran = 0 back = 0 us = m while ind < n: back = ind - ran while us - l[ind] < 0: if back == ind: break us += l[back] back += 1 if ran > 0: ran -= 1 if us - l[ind] >= 0: us -= l[ind] ran += 1 ind += 1 maxi = max(maxi, ran) print(maxi)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def f(): return [int(i) for i in input().split()] [n, t], a = f(), f() max_read = 0 books_read = 0 time = 0 for i in range(n): if books_read > 0: books_read -= 1 time -= a[i - 1] i += books_read for j in range(i, n): if time + a[j] <= t: time += a[j] books_read += 1 if books_read > max_read: max_read = books_read else: break print(max_read)
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = list(map(int, input().split())) a = list(map(int, input().split())) i = n - 1 s = 0 while i >= 0 and s <= t: s += a[i] i -= 1 if i >= 0: i += 1 s -= a[i] j = n - 2 max_res = n - 1 - i while j >= 0 and i >= 0: s -= a[j + 1] while i >= 0 and s <= t: s += a[i] i -= 1 res = j - i - 1 if i < 0 and s <= t: res += 1 if res > max_res: max_res = res j -= 1 if i >= 0: i += 1 s -= a[i] print(max_res) else: print(n if s <= t else n - 1)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR WHILE VAR NUMBER VAR NUMBER VAR VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
first = input("").split() n = int(first[0]) t = int(first[1]) data = list(map(int, input("").split())) total = 0 lst = list() max_len = len(lst) - 1 for i in range(0, n): total = total + data[i] lst.append(data[i]) while total > t: if len(lst) > max_len: max_len = len(lst) - 1 total = total - lst[0] lst.pop(0) if len(lst) > max_len: max_len = len(lst) print(max_len)
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR WHILE VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
tt = 1 for i in range(tt): n, t = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] p = 0 s = 0 rec = 0 l = 0 for i in range(n): if arr[i] > t: p = i + 1 s = 0 l = 0 continue s += arr[i] l += 1 while s > t: s -= arr[p] p += 1 l -= 1 rec = max(rec, l) print(rec)
ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = list(map(int, input().split())) sumA = 0 c = 0 i = 0 j = 0 sumA = 0 ans = [] c = 0 while i < n: check = 1 for k in range(j, n): sumA += a[k] if sumA > t: check = 0 ans.append(c) goback = k sumA -= a[i] while sumA > t: sumA -= a[goback] goback -= 1 c -= 1 j = goback + 1 break else: c += 1 if check: ans.append(c) break i += 1 print(max(ans))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def canBeRead(n, totalTime, times): total = totalTime tot1 = 0 tot2 = 0 for i in times[:n]: tot1 += i if tot1 <= totalTime: return True else: for j in range(n, len(times)): tot1 -= times[j - n] tot1 += times[j] if tot1 <= totalTime: return True return False def BS(data, n, t): l = 0 r = n ans = 0 while l <= r: m = (l + r) // 2 if canBeRead(m, t, data): ans = m l = m + 1 else: r = m - 1 return ans n, t = map(int, input().split(" ")) data = list(map(int, input().split(" "))) d = BS(data, n, t) print(d)
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR IF VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = input().strip().split() n = int(n) t = int(t) a = input().strip().split() for index, item in enumerate(a): a[index] = int(item) i = 0 j = 0 s = 0 ans = 0 while j < n: s += a[j] if s <= t: ans = max(ans, j - i + 1) else: while s > t: s -= a[i] i += 1 j += 1 print(ans)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) l = list(map(int, input().split())) sum = 0 max = 0 c = 0 for i in range(n): if sum + l[i] <= t: sum = sum + l[i] c = c + 1 elif sum != 0: sum = sum - l[i - c] + l[i] if c > max: max = c print(max)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) l = [int(x) for x in input().split()] ar = [0] temp = 0 for i in l: temp += i ar.append(temp) i = 0 j = 1 m = 0 while j != n + 1: if abs(ar[i] - ar[j]) <= t: if m < abs(i - j): m = abs(i - j) j += 1 else: i += 1 j += 1 print(m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR IF VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n_livros, tempo_livre = map(int, input().split()) minutos_livro = list(map(int, input().split())) i, j, cont, livros_lidos = 0, 0, 0, 0 while i < n_livros: cont += minutos_livro[i] if cont > tempo_livre: cont -= minutos_livro[j] j += 1 livros_lidos = i - j + 1 i += 1 print(livros_lidos)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER WHILE VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = list(map(int, input().split())) s = 0 arr = [] for i in range(n): s += a[i] arr.append(s) def binary(arr, mid, n, t): start = 0 end = n - 1 while start <= end: pivot = (start + end) // 2 if arr[pivot] - mid <= t: start = pivot + 1 else: end = pivot - 1 return end m = binary(arr, 0, n, t) + 1 for i in range(1, n): temp = binary(arr, arr[i - 1], n, t) - i + 1 m = max(temp, m) print(m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, M = map(int, input().split()) a = list(map(int, input().split())) j = 0 m = 0 sum1 = 0 count = 0 for i in range(n): sum1 = sum1 + a[i] count += 1 while sum1 >= M: if sum1 == M: count = count m = max(count, m) sum1 = sum1 - a[j] count = count - 1 else: count = count - 1 m = max(m, count) sum1 = sum1 - a[j] j = j + 1 m = max(m, count) print(m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, k = input().split() n = int(n) k = int(k) a = [int(x) for x in input().split()] l = 0 r = 0 s = 0 m = 0 for i in range(n): while s <= k: m = max(r - i, m) if r == n: break s += a[r] r += 1 s -= a[i] print(m)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = [int(x) for x in input().split()] right, left, books, sum = 0, 0, 0, 0 while left != n: sum += a[left] if sum <= t and books < left + 1 - right: books = left + 1 - right elif sum > t: sum -= a[right] right += 1 left += 1 print(books)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER WHILE VAR VAR VAR VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) B = [int(i) for i in input().split()] i, j, sum, res = 0, 0, B[0], 0 while j < len(B) - 1 and i < len(B): if sum <= t: res = max(res, j - i + 1) j = j + 1 sum = sum + B[j] else: sum = sum - B[i] i = i + 1 if sum <= t: res = max(res, j - i + 1) print(res)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER VAR NUMBER NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def solve(N, T, A): sum = [0, int(A[0])] for i in range(1, N): sum.append(int(A[i]) + sum[i]) count = 0 j = 0 for i in range(1, N + 1): while sum[i] - sum[j] > T: j += 1 count = max(count, i - j) return count num_input = input() num_input = num_input.split(" ") N = int(num_input[0]) T = int(num_input[1]) A = input() A = A.split(" ") print(solve(N, T, A))
FUNC_DEF ASSIGN VAR LIST NUMBER FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = input().split() n = int(n) t = int(t) a = [int(item) for item in input().split()] j = 0 max_item = 0 total = 0 count = 0 for i in range(n): while j < n: total = total + a[j] if total > t: break else: count = count + 1 j = j + 1 max_item = max(max_item, count) total = total - a[i] j = j + 1 print(max_item)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, m = map(int, input().split()) d = list(map(int, input().split())) s = 0 r = 0 i = j = 0 ans = 0 while i < n and j < n: if s + d[j] <= m: r += 1 s += d[j] j += 1 else: r = max(r - 1, 0) s = max(s - d[i], 0) i += 1 j = max(i, j) ans = max(ans, r) print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
while True: try: def solution(a, n, t): j = tsum = i = 0 while i < n: tsum = tsum + a[i] if tsum > t: tsum -= a[j] j += 1 i += 1 print(n - j) def read(): n, t = map(int, input().split()) a = list(map(int, input().split())) solution(a, n, t) if __name__ == "__main__": read() except EOFError: break
WHILE NUMBER FUNC_DEF ASSIGN VAR VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def soln(arr, t): result = 0 L, R = 0, 0 currSum = 0 while R < len(arr): if currSum + arr[R] <= t: currSum += arr[R] R += 1 result = max(result, R - L) else: currSum -= arr[L] L += 1 return result def main(): n, t = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] result = soln(arr, t) print(result) main()
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = list(map(int, input().split())) a = list(map(int, input().split())) res = 0 i = 0 j = 0 ts = 0 while i < n: if a[i] > t: i += 1 continue if ts == 0: ts += a[i] res = max(1, res) j = i + 1 while j < n and ts + a[j] <= t: ts += a[j] j += 1 res = max(j - i, res) if j == n: break ts -= a[i] i += 1 print(res)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def books(t, books): i = 0 j = 0 ds = [0] sum = 0 while i < len(books) and j < len(books): if sum + books[j] > t: sum -= books[i] i += 1 else: sum += books[j] j += 1 ds.append(j - i) return max(ds) n, t = [int(x) for x in input().split()] b = [int(x) for x in input().split()] print(books(t, b))
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def pointers(n, t, array): if t <= 0: return 0 start, end = 0, 0 ans = 0 curr = 0 while end < n: curr += array[end] while curr > t: curr -= array[start] start += 1 ans = max(end - start + 1, ans) end += 1 return ans n, t = input().split() n, t = int(n), int(t) books = list(map(int, input().split())) print(pointers(n, t, books))
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def main(): n, t = map(int, input().split()) l = list(map(int, input().split())) start = stop = 0 res = [] try: while True: while t >= 0: res.append(stop - start) if stop == n: raise StopIteration t -= l[stop] stop += 1 while t < 0: t += l[start] start += 1 except StopIteration: print(max(res)) main()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST WHILE NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = list(map(int, input().split())) i = j = 0 ans = 0 temp = 0 while j < n: if t >= a[j]: temp += 1 t -= a[j] j += 1 elif i + 1 < n: t += a[i] if i < j else 0 i += 1 ans = max(temp, ans) temp = temp - 1 if i <= j else 0 j = max(j, i) else: break ans = max(ans, temp) print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
from sys import stdin def libros(n, t, libros): con = 0 a = 0 men = 0 may = 0 while men < n: while may < n and con + libros[may] <= t: con += libros[may] may += 1 b = may - men if b > a: a = b con -= libros[men] men += 1 return a def main(): n, t = stdin.readline().strip().split() n = int(n) t = int(t) tlibros = [int(x) for x in stdin.readline().strip().split()] z = libros(n, t, tlibros) print(z) main()
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) books = [int(i) for i in input().split()] back = 0 front = 0 ans = 0 tmp = 0 while front < n: if tmp + books[front] <= t: tmp += books[front] front += 1 else: tmp += books[front] if front - back > ans: ans = front - back while tmp > t: tmp -= books[back] back += 1 front += 1 if front - back > ans: ans = front - back print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def sol(a, n, t): i, j, ans, tans = 0, 0, 0, 0 while j < n: if a[j] <= t: tans += 1 t -= a[j] j += 1 else: ans = max(ans, tans) while j < n and a[j] > t: if i != j: t += a[i] i += 1 tans -= 1 else: i += 1 j += 1 ans = max(ans, tans) return ans n, t = map(int, input().split()) a = [int(i) for i in input().split()] print(sol(a, n, t))
FUNC_DEF ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR WHILE VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = [0] a += list(map(int, input().split())) for i in range(1, n + 1): a[i] += a[i - 1] l = 0 lb = 0 rb = 0 nb = 0 for r in range(1, n + 1): while a[r] - a[l] > t: l += 1 if r - l > nb: rb = r lb = l nb = r - l print(nb)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
arr = [0] * 200000 tt = [0] * 200000 ans = 0 nt = input().split() n = int(nt[0]) t = int(nt[1]) isi = input().split() for i in range(1, n + 1, 1): arr[i] = int(isi[i - 1]) kiri = 1 r = 0 for i in range(1, n + 1, 1): if arr[i] <= t: kiri = i r = i break tt[kiri - 1] = 2 * arr[kiri] arr[kiri - 1] = arr[kiri] for i in range(kiri, n + 1, 1): kiri = i tt[i] = tt[i - 1] - arr[i - 1] for j in range(r + 1, n + 1, 1): if tt[i] + arr[j] <= t: tt[i] += arr[j] r = j else: r = j - 1 break if ans < r - kiri + 1: ans = r - kiri + 1 print(ans)
ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = list(map(int, input().split())) sum1 = 0 maxbooks = 0 p1 = 0 p2 = 0 while p1 < n and p2 < n: if sum1 + a[p2] > t: maxbooks = max(maxbooks, p2 - p1) sum1 = max(0, sum1 - a[p1]) p1 += 1 else: sum1 += a[p2] p2 += 1 if p2 < p1: p2 = p1 print(max(maxbooks, p2 - p1))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) al = list(map(int, input().split())) al = [0] + al for i in range(1, n + 1): al[i] += al[i - 1] j = 1 su = 0 ans = 0 for i in range(1, n + 1): while j <= n and al[j] - al[i - 1] <= t: j += 1 ans = max(ans, j - i) print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) l = list(map(int, input().split())) start, res = 0, [] for stop, a in enumerate(l): t -= a while t < 0: t += l[start] start += 1 res.append(stop - start) print(max(res) + 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER LIST FOR VAR VAR FUNC_CALL VAR VAR VAR VAR WHILE VAR NUMBER VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) mat = list(map(int, input().split())) cnt = 0 tail = 0 res = 0 for i in range(n): cnt += mat[i] while cnt > t: cnt -= mat[tail] tail += 1 if res < i - tail + 1: res = i - tail + 1 print(res)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
class Solution: def __init__(self): self.n, self.t = [int(x) for x in input().split()] self.a = [int(x) for x in input().split()] def solve_and_print(self): i = s = 0 for j in range(self.n): s += self.a[j] if s > self.t: s -= self.a[i] i += 1 print(self.n - i) Solution().solve_and_print()
CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL FUNC_CALL VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
r = lambda: map(int, input().split()) n, t = r() a = list(r()) i = 0 s = 0 u = 0 while i < n: s += a[i] if s > t: s -= a[u] u += 1 i += 1 print(n - u)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
s = input().split() n = int(s[0]) t = int(s[1]) s = input().split() for i in range(len(s)): s[i] = int(s[i]) l = 0 r = 0 v = s[0] res = 0 while r < len(s): if v <= t: res = max([res, r - l + 1]) if r == len(s) - 1: break else: r += 1 v += s[r] elif v > t: v -= s[l] l += 1 print(res)
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
a1 = [int(s) for s in input().split()] a2 = [int(s) for s in input().split()] nullArray = [0] a2 = nullArray + a2 i = 0 j = 0 minutes = a1[1] runningTotal = 0 maximum = 0 for i in range(0, len(a2)): runningTotal -= a2[i] while j + 1 < len(a2) and runningTotal + a2[j + 1] <= minutes: j += 1 runningTotal += a2[j] score = j - i if score > maximum: maximum = score print(maximum)
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR WHILE BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
import sys def binary(arraySum, n, value): low, high = 0, n while low <= high: mid = (low + high) // 2 if arraySum[mid] == value: return mid elif arraySum[mid] > value: high = mid - 1 else: low = mid + 1 return high def main(): n, t = [int(x) for x in sys.stdin.readline().strip().split()] lista = [int(x) for x in sys.stdin.readline().strip().split()] arraySum = [lista[0]] for i in range(1, n): arraySum.append(arraySum[i - 1] + lista[i]) arraySum.insert(0, 0) books = 0 for i in range(n): j = binary(arraySum, n, t + arraySum[i]) books = max(books, j - i) print(books) main()
IMPORT FUNC_DEF ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = input().split() n, t = int(n), int(t) l = list(map(int, input().split())) sum = 0 j = 0 ans = 0 for i in range(n): if l[i] + sum <= t: sum = sum + l[i] else: sum = sum + l[i] while sum > t: sum = sum - l[j] j += 1 ans = max(ans, i + 1 - j) print(ans)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = [int(s) for s in input().rstrip().split(" ")] b = [int(s) for s in input().rstrip().split(" ")] i = 0 j = 0 ans = 0 s = 0 while j < n: if s + b[j] <= t: s += b[j] ans = max(ans, j - i + 1) j += 1 elif i == j: j += 1 i += 1 else: s -= b[i] i += 1 print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
mt = list(map(int, input().split())) n = mt[0] T = mt[1] A = list(map(int, input().split())) res = 0 cnt = 0 t = T suffix = [0] * (len(A) + 1) for i in range(1, len(A) + 1, 1): suffix[i] = suffix[i - 1] + A[i - 1] l = 1 r = 1 while l < len(suffix) and r < len(suffix): if suffix[r] - suffix[l - 1] <= T: cnt = r - l + 1 r += 1 else: l += 1 res = max(res, cnt) cnt = 0 print(max(res, cnt))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
inputs = [int(x) for x in input().split()] mins = inputs[1] book_times = [int(x) for x in input().split()] current_max = -1 current_time = 0 start_idx = 0 end_idx = -1 for i in range(len(book_times)): t = book_times[i] if t + current_time > mins: current_max = ( end_idx - start_idx if end_idx - start_idx > current_max else current_max ) while start_idx <= end_idx and t + current_time > mins: current_time -= book_times[start_idx] start_idx += 1 if t + current_time <= mins: current_time += t else: current_time = 0 start_idx = i + 1 end_idx = i current_max = end_idx - start_idx if end_idx - start_idx > current_max else current_max print(current_max + 1)
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
from sys import stdin n, t = map(int, stdin.readline().rstrip().split(" ")) nums = list(map(int, stdin.readline().rstrip().split(" "))) l = r = 0 m = float("-inf") s = nums[0] while r < len(nums): if s == t: m = max(m, r - l + 1) s -= nums[l] l += 1 elif s > t: s -= nums[l] l += 1 else: m = max(m, r - l + 1) r += 1 if r < len(nums): s += nums[r] print(m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) v = list(map(int, input().split())) tmp = t ans = 0 a = 0 l = 0 for i in range(len(v)): if v[i] > t: l = i + 1 a = 0 tmp = t else: while tmp < v[i]: a -= 1 tmp += v[l] l += 1 a += 1 tmp -= v[i] ans = max(ans, a) print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = list(map(int, input().split())) b = [a[0]] ans = 0 for i in range(1, n): b.append(b[i - 1] + a[i]) j = 0 for i in range(n): while j < n and b[j] - b[i] + a[i] <= t: j += 1 if b[j - 1] - b[i] + a[i] <= t and j - i > ans: ans = j - i print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
import sys input = sys.stdin.readline x, y = map(int, input().split()) (*li,) = map(int, input().split()) li2 = [0] * x li2[-1] = 1 if li[-1] <= y else 0 sum1 = li[-1] ans = li2[-1] j = x - 1 for i in range(x - 2, -1, -1): if li[i] > y: li2[i] = 0 sum1 = 0 j = i - 1 continue sum1 += li[i] if sum1 <= y: li2[i] = li2[i + 1] + 1 else: cnt = li2[i + 1] + 1 while sum1 > y: sum1 -= li[j] j -= 1 cnt -= 1 li2[i] = cnt ans = max(ans, li2[i]) print(ans)
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def ans(b, n, t): if sum(b) <= t: return n i = 0 ans = 0 while i < n and b[i] > t: i += 1 if i < n: ans = 1 t -= b[i] j = i + 1 while j < n: if b[j] <= t: tmp = j - i + 1 if tmp > ans: ans = tmp t -= b[j] j += 1 else: while b[j] > t and i < j: t += b[i] i += 1 if i == j: while i < n and b[i] > t: i += 1 if i < n: t -= b[i] j = i + 1 return ans n, t = map(int, input().split()) books = [int(i) for i in input().split()] print(ans(books, n, t))
FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
a, b = map(int, input().split()) l = list(map(int, input().split())) i = 0 j = 0 m = 0 count = 0 while j < len(l): if l[j] <= b: count += 1 b -= l[j] j = j + 1 m = max(m, count) elif i < j: b += l[i] count -= 1 i = i + 1 else: i += 1 j += 1 print(m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def solve(arr, n, time): sum1, count = 0, 0 j = -1 for i in range(n): if sum1 + arr[i] <= time: sum1 += arr[i] else: sum1 += arr[i] while sum1 > time: j += 1 sum1 -= arr[j] count = max(count, i - j) return count n, t = map(int, input().split(" ")) arr = list(map(int, input().split(" "))) print(solve(arr, n, t))
FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR WHILE VAR VAR VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = list(map(int, input().split())) sum1 = 0 z = 0 j = 0 k = 0 for x in range(n): z += 1 sum1 += a[x] while sum1 > t: sum1 -= a[j] j += 1 z -= 1 if z > k: k = z if z > k: k = z print(k)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
a, b = map(int, input().split()) l = list(map(int, input().split())) k = 0 c = 0 s = 0 for i in range(len(l)): s = s + l[i] if s <= b: c = c + 1 else: s = s - l[k] k = k + 1 print(c)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, k = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] start = 0 end = 0 ans = 0 s = 0 l = 0 while end < n: s += arr[end] l += 1 if s <= k: ans = max(ans, l) while start <= end and s > k: if s <= k: ans = max(ans, l) l -= 1 s -= arr[start] start += 1 if s <= k: ans = max(ans, l) end += 1 if s <= k: ans = max(ans, l) print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR WHILE VAR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
s = list(map(int, input().split())) if int(s[0]) >= 1 and int(s[0]) <= 100000: n = int(s[0]) if int(s[1]) >= 1 and int(s[1]) <= 1000000000: t = int(s[1]) b_list = list(map(int, input().split())) book_read = 0 sum_count = 0 counter = 0 finish = -1 while counter < len(b_list): if b_list[counter] > t: sum_count = 0 finish = counter counter += 1 continue if sum_count + b_list[counter] <= t: sum_count += b_list[counter] book_read = max(book_read, counter - finish) counter += 1 else: if sum_count + b_list[counter] > t: sum_count -= b_list[finish + 1] finish += 1 sum_count += b_list[counter] book_read = max(book_read, counter - finish) counter += 1 print(book_read)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
l1 = input() ant = l1.split() n = int(ant[0]) t = int(ant[1]) l2 = input() aa = l2.split() a = [] for i in range(0, n): ai = int(aa[i]) a.append(ai) start = 0 max = 0 sum = 0 for i in range(0, n): sum += a[i] if sum <= t: max += 1 else: sum = sum - a[start] start += 1 print(max)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) books = [int(i) for i in input().split()] ans = 0 tmp_ans = 0 count = 0 i = 0 j = i while i < n: if books[i] > t: j = i if ans < tmp_ans: ans = tmp_ans tmp_ans = 0 else: count += books[i] if count <= t: tmp_ans += 1 else: while count > t: count -= books[j] j += 1 if ans < tmp_ans: ans = tmp_ans tmp_ans = i - j + 1 i += 1 if tmp_ans > ans: print(tmp_ans) else: print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR VAR VAR IF VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
g = input() n, t = [int(x) for x in g.split()] r = input() li = [] if n > 1: for y in r.split(): li.append(int(y)) else: li.append(int(r)) lis = [] flag = 0 tt = 0 l = 0 d = 0 j = 0 for i in range(n): l += 1 d += li[i] if d > t: if l == 1: flag = 1 tt = 0 break else: break j = i tt += 1 if flag == 0: lis.append(tt) else: lis.append(0) if j == n - 1: print(tt) else: hjk = j + 2 if j == 0 and flag == 1: hjk = j + 1 ilk = 0 while hjk < n: d += li[hjk] - li[ilk] ilk += 1 if d <= t: tt += 1 if hjk == n - 1: break for g in range(hjk + 1, n): d += li[g] if d > t: break else: tt += 1 hjk = g + 1 else: hjk += 1 print(tt)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR IF VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, k = map(int, input().split()) l = list(map(int, input().split())) s = [0] * (n + 1) s[0] = 0 for i in range(1, n + 1): s[i] = s[i - 1] + l[i - 1] last = n no = 0 r = n while r >= 0: if s[last] - s[r] > k: no = max(no, last - r - 1) last -= 1 r += 1 r -= 1 no = max(no, last - r - 1) print(no)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) times = list(map(int, input().split())) + [0] for i in range(1, n): times[i] += times[i - 1] l = 0 r = n + 1 while l + 1 < r: label = False m = (r + l) // 2 for i in range(m - 1, n): if times[i] - times[i - m] <= t: label = True break if label: l = m else: r = m print(l)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = list(map(lambda x: int(x), input().split())) a = list(map(lambda x: int(x), input().split())) maximum = 0 i = 0 j = 1 s = a[i] maximum = 0 if len(a) == 1 and a[0] <= t: print(1) else: while i < len(a) and j < len(a): if s + a[j] <= t: s = s + a[j] j += 1 if j - i > maximum: maximum = j - i else: s = s - a[i] i += 1 print(maximum)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def bs(a, t): d = 0 c = 0 for i in range(len(a)): d += a[i] if d > t: d -= a[c] c += 1 return len(a) - c n, t = map(int, input().split()) a = [int(i) for i in input().split()] print(bs(a, t))
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
startIndex = 0 endIndex = 0 timeSum = 0 counter = 0 n, t = map(int, input().split()) timeList = input().split() for i in range(n): timeSum += int(timeList[i]) endIndex = i if timeSum > t: timeSum -= int(timeList[startIndex]) startIndex += 1 if counter < endIndex - startIndex + 1: counter = endIndex - startIndex + 1 print(counter)
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
l = 0 r = -1 segL, time = [int(x) for x in input().split()] a = [int(x) for x in input().split()] segSum = 0 segments = [] while r < segL - 1: r += 1 segSum += a[r] if segSum == time: segments.append(r + 1 - l) segSum -= a[l] l += 1 elif segSum > time: segments.append(r - l) while segSum >= time: segSum -= a[l] l += 1 else: segments.append(r + 1 - l) print(max(segments))
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def maxBookRead(book_minutes, quota): i = 0 j = 0 total_minutes = book_minutes[0] max_book = 0 while i <= len(book_minutes) - 1 and j <= len(book_minutes) - 1: count = j - i + 1 while total_minutes <= quota and j < len(book_minutes) - 1: j += 1 total_minutes += book_minutes[j] count += 1 if total_minutes > quota: count -= 1 if max_book < count: max_book = count total_minutes -= book_minutes[i] i += 1 return max_book n, m = list(map(int, input().split())) book_minutes = list(map(int, input().split())) print(maxBookRead(book_minutes, m))
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, m = map(int, input().split()) s = 0 c = 0 cnt = 0 a = list(map(int, input().split())) for i in range(len(a)): s = s + a[i] if s <= m: cnt = cnt + 1 else: s = s - a[c] c = c + 1 print(cnt)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
ino = list(map(int, input().split())) n = ino[0] t = ino[1] summ = 0 k = 0 i = 0 maxx = -1 j = 0 a = list(map(int, input().split())) while j < n: if summ + a[j] <= t: summ += a[j] j += 1 else: summ -= a[i] i += 1 if j - i > maxx: maxx = j - i print(maxx)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
a = input() b = input() num_books, max_time = [int(i) for i in a.split()] read_time = [int(i) for i in b.split()] max_val = 0 j = 0 count = 0 time = 0 for i in range(num_books): time += read_time[i] count += 1 while time > max_time: time -= read_time[j] j += 1 count -= 1 max_val = max(count, max_val) print(max_val)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) arr = list(map(int, input().split())) longest = curr = s = i = 0 while i < n: if s > t: longest = max(curr - 1, longest) s -= arr[i - curr] curr -= 1 else: s += arr[i] curr += 1 i += 1 while s > t: longest = max(curr - 1, longest) s -= arr[i - curr] curr -= 1 longest = max(curr, longest) print(longest)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) count = 0 a = list(map(int, input().split()))[:n] c = 0 d = 0 for i in range(len(a)): d += a[i] if d > t: d -= a[c] c += 1 print(n - c)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) b = list(map(int, input().split())) l = 0 r = 0 s = b[r] mx = 0 while r < n - 1 or l < n: if s <= t and r < n - 1: r += 1 s += b[r] elif r == n - 1 and s <= t: mx = max(mx, r - l + 1) break elif r < n - 1: mx = max(mx, r - l) s -= b[l] l += 1 else: s -= b[l] l += 1 print(mx)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = input().split() for i in range(n): a[i] = int(a[i]) b = [] c = [0] i = 0 count = 0 while i < n: if t >= a[i]: b.append(a[i]) t -= a[i] count += 1 elif len(b) > 0: c.append(count) t += b[0] b.pop(0) count -= 1 i -= 1 i += 1 c.append(count) print(max(c))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = list(map(int, input().split())) a = [0] + a for i in range(1, len(a)): a[i] += a[i - 1] l = 1 r = 1 res = 0 while l <= n: while r <= n and a[r] - a[l - 1] <= t: r += 1 r -= 1 res = max(res, r - l + 1) l += 1 print(res)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def read_input(): n, t = [int(i) for i in input().split(" ")] a = [int(i) for i in input().split(" ")] return n, t, a def read_them(n, t, a): ts = [0] * len(a) cs = [0] * len(a) start_pos = 0 time_remain = t while start_pos < len(a): i = cs[max(start_pos - 1, 0)] + max(start_pos - 1, 0) while i < len(a) and time_remain >= a[i]: time_remain -= a[i] i += 1 ts[start_pos] = time_remain cs[start_pos] = i - start_pos time_remain += a[start_pos] start_pos += 1 return max(cs) def main(): n, t, a = read_input() count = read_them(n, t, a) print(count) main()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING RETURN VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) booklist = list(map(int, input().split())) pfs = [] pfs.append(0) for i in range(n): pfs.append(pfs[i] + booklist[i]) def isPossible(nbooks): ttimes = [(pfs[i + nbooks] - pfs[i]) for i in range(n - nbooks + 1)] for tt in ttimes: if tt <= t: return True return False lo = 0 hi = n while lo < hi: mid = lo + (hi - lo + 1) // 2 if isPossible(mid): lo = mid else: hi = mid - 1 print(lo)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) l = list(map(int, input().split())) ma = j = k = kt = 0 for i in range(n): if l[i] + kt <= t: k += 1 kt += l[i] if ma < k: ma = k else: while l[i] + kt > t: if k == 0: j = i + 1 break kt -= l[j] k -= 1 j += 1 if kt + l[i] <= t: k += 1 kt += l[i] if ma < k: ma = k print(ma)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def maxBooks1(n, t, arr): mx = 0 for i in range(0, n): for j in range(i, n): sum = 0 for k in range(i, j + 1): sum += arr[k] segmenLen = j - i + 1 if sum <= t and segmenLen > mx: mx = segmenLen return mx def maxBooks2(n, t, arr): mx = 0 for i in range(0, n): sum = 0 for j in range(i, n): sum += arr[j] segmenLen = j - i + 1 if sum <= t and segmenLen > mx: mx = segmenLen return mx def maxBooks3(n, t, arr): mx = 0 i = 0 sum = 0 for j in range(0, n): sum += arr[j] while sum > t: sum -= arr[i] i += 1 segmenLen = j - i + 1 if segmenLen > mx: mx = segmenLen return mx n, t = input().split(" ") n = int(n) t = int(t) arr = input().split(" ") arr = [int(x) for x in arr] print(maxBooks3(n, t, arr))
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, l = map(int, input().strip().split()) a = list(map(int, input().strip().split())) i, j = -1, 0 s, ans = 0, 0 while j != n: s = s + a[j] while s > l: i = i + 1 s = s - a[i] if j - i > ans: ans = j - i j = j + 1 print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, k = map(int, input().split()) a = [int(x) for x in input().split()] i = 0 j = 0 mx = 0 sm = 0 if n == 1: if a[0] > k: print(0) else: print(1) else: while j < n: sm += a[j] if sm > k: sm -= a[i] i += 1 ln = j - i + 1 if ln > mx: mx = ln j += 1 print(mx)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER WHILE VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) A = list(map(int, input().split())) A.insert(0, 0) m = 0 count = 0 li = 1 ri = 1 for i in range(1, n + 1): count += A[ri] if count == t: books = ri - li + 1 if m < books: m = books while count > t: books = ri - li if m < books: m = books count -= A[li] li += 1 ri += 1 if count < t: books = ri - li if m < books: m = books print(m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
first_line = list(map(int, input().split())) n = first_line[0] t = first_line[1] a = list(map(int, input().split())) def main(): sum = 0 ans = 0 i, l = 0, 0 while i < n: sum += a[i] while sum > t: sum -= a[l] l += 1 ans = max(ans, i - l + 1) i += 1 print(ans) return main()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
books_count, free_time = input().split(" ") books_count, free_time = int(books_count), int(free_time) books = input().split(" ") books_timing = [int(book) for book in books] biggest_count = 0 counter = 1 x = 0 start = 0 end = 0 total = books_timing[0] z = 0 looped_all = False while total > free_time: if z == len(books_timing) - 1: looped_all = True break if books_timing[z] < free_time: start = z end = z total = books_timing[z] counter = 1 biggest_count = counter x = z z += 1 if looped_all: print("0") else: while True: if end == len(books_timing) - 1: if biggest_count < counter: biggest_count = counter break if total + books_timing[end + 1] <= free_time: end += 1 total += books_timing[end] counter += 1 else: while total + books_timing[end + 1] > free_time: total -= books_timing[start] counter -= 1 start += 1 end += 1 total += books_timing[end] counter += 1 if counter > biggest_count: biggest_count = counter x += 1 print(biggest_count)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING WHILE NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def main(): n, t = list(map(int, input().split())) a = list(map(int, input().split())) be = 0 en = -1 time = 0 ans = 0 while en < n - 1: while time <= t and en < n - 1: ans = max(ans, en - be + 1) en += 1 time += a[en] while time > t: time -= a[be] be += 1 ans = max(ans, en - be + 1) print(ans) main()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n_books, n_time_reading = list(map(int, input().split())) minutes = list(map(int, input().split())) def get_max_with_o_n_2(): my_max = 0 for i in range(n_books): total = 0 count = 0 for j in range(i, n_books): total += minutes[j] if total <= n_time_reading: count += 1 else: break if count == n_books: return n_books if count >= my_max: my_max = count return my_max def get_the_first_array(n_books, n_time_reading, minutes): first_count = 0 first_value = 0 for i in range(n_books): first_value += minutes[i] if first_value <= n_time_reading: first_count += 1 else: return [i - 1, first_count, first_value - minutes[i]] return [n_books, first_count, first_value] def get_max_with_o_n(n_books, n_time_reading, minutes): if n_books == 1: if minutes[0] <= n_time_reading: return 1 else: return 0 j, first_count, first_value = get_the_first_array(n_books, n_time_reading, minutes) my_max = first_count if my_max == n_time_reading: return my_max for i in range(1, n_books): first_value -= minutes[i - 1] first_count -= 1 j += 1 while j <= n_books - 1: first_value += minutes[j] if first_value <= n_time_reading: j += 1 first_count += 1 else: first_value -= minutes[j] j -= 1 break if first_count > my_max: my_max = first_count return my_max print(get_max_with_o_n(n_books, n_time_reading, minutes))
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR RETURN VAR IF VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER RETURN LIST BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR RETURN LIST VAR VAR VAR FUNC_DEF IF VAR NUMBER IF VAR NUMBER VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR RETURN VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
def solve(A, k): i, j = 0, 0 mx = 0 while j < len(A): k -= A[j] while i < len(A) and k < 0: k += A[i] i += 1 mx = max(mx, j - i + 1) j += 1 return mx k = int(input().split(" ")[1]) arr = input().split(" ") A = [int(n) for n in arr] print(solve(A, k))
FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().split()) a = [int(i) for i in input().split()] start = 0 max1 = 0 sum = a[0] for i in range(1, len(a) + 1): if sum <= t: max1 = max(max1, i - start) while i < len(a) and sum + a[i] > t and start < i: sum -= a[start] start += 1 if i < len(a): sum += a[i] print(max1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR WHILE VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
from itertools import accumulate n, t = map(int, input().split()) a = [int(x) for x in input().split()] def prefixsums(arr): from itertools import accumulate pref = [0] + list(accumulate(arr)) return lambda l, r: pref[r] - pref[l - 1] get = prefixsums(a) r = 1 ans = 0 for l in range(1, n + 1): while r <= n and get(l, r) <= t: r += 1 ans = max(ans, r - l) print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, t = map(int, input().strip().split()) l = list(map(int, input().strip().split())) g = 0 left = 0 right = 0 curr = 0 while True: if right == n: break curr += l[right] right += 1 if curr > t: while curr > t: curr -= l[left] left += 1 g = max(g, right - left) print(g)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR
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. -----Input----- The first line contains two integers n and t (1 ≀ n ≀ 10^5;Β 1 ≀ t ≀ 10^9) β€” 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} ≀ 10^4), where number a_{i} shows the number of minutes that the boy needs to read the i-th book. -----Output----- Print a single integer β€” the maximum number of books Valera can read. -----Examples----- Input 4 5 3 1 2 1 Output 3 Input 3 3 2 2 3 Output 1
n, k = list(map(int, input().split())) l = list(map(int, input().split())) ma = 0 sum = 0 s = 0 end = 0 while s < n and end < n: while sum > k and s < end: sum = sum - l[s] s = s + 1 sum = sum + l[end] end = end + 1 if sum <= k and end - s > ma: ma = end - s print(ma)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR WHILE VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR