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
|
n, t = map(int, input().split(" "))
read_times = list(map(int, input().split(" ")))
max_books = -1
r = 0
cur_sum = read_times[0]
for i in range(len(read_times)):
if i > 0:
cur_sum -= read_times[i - 1]
while r < n - 1 and cur_sum <= t:
r += 1
cur_sum += read_times[r]
d = r - i if cur_sum > t else r - i + 1
if d > max_books:
max_books = d
print(max_books)
|
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 VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP 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 = map(int, input().split())
a = list(map(int, input().split()))
def Max_number_of_book_can_read(a, n, t):
ans = 0
i = index = 0
count = 0
while i < n:
if t >= a[i]:
t -= a[i]
count += 1
i += 1
else:
t += a[index]
count -= 1
i = index + count + 1
index += 1
if count >= ans:
ans = count
return ans
print(Max_number_of_book_can_read(a, n, t))
|
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 FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER 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
|
n, t = map(int, input().split())
a = list(map(int, input().split()))
s = [0, *a]
for i in range(1, n + 1):
s[i] = s[i - 1] + s[i]
ans = 0
p = 1
for i in range(1, n + 1):
while p < n and s[p] - s[i - 1] < t:
p += 1
if s[p] - s[i - 1] > t:
p -= 1
ans = max(ans, p - i + 1)
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 NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR 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 IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR 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
|
def fun(t, nums):
le = len(nums)
l = 0
r = 1
if le == 1:
if t < nums[0]:
return 0
else:
return 1
sum = 0
books = 0
k = 0
for i in range(le):
sum += nums[i]
if sum <= t:
books += 1
else:
sum -= nums[k]
k += 1
return books
var1, var2 = [int(x) for x in input().split()]
user_input = input().split(" ")
numbers = [int(x.strip()) for x in user_input]
print(fun(var2, numbers))
|
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL 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 = list(map(int, input().split()))
start = end = temp = ans = curmax = 0
while end < n:
if temp + a[end] <= t:
temp += a[end]
end += 1
else:
curmax = end - start
if curmax > ans:
ans = curmax
temp -= a[start]
curmax -= 1
start += 1
ans = max(ans, end - start)
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 VAR VAR VAR NUMBER WHILE VAR VAR IF 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 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())
a = list(map(int, input().split()))
s = 0
ct = 0
high = 0
le = 0
ri = 0
try:
while True:
if a[ri] + s > t:
if ct > high:
high = ct
s -= a[le]
le += 1
ct -= 1
s += a[ri]
ri += 1
ct += 1
except IndexError:
if ct > high:
high = ct
print(high)
|
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 WHILE NUMBER IF BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER 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())
times = list(map(int, input().split()))
start = -1
for i in range(len(times)):
if times[i] <= t:
start = i
break
if start == -1:
print(0)
exit()
start_i = start
end_i = start
cur = 1
max = 1
time_holder = times[start]
end_i += 1
while end_i < n:
next_time = times[end_i]
if time_holder + next_time <= t:
time_holder += next_time
cur += 1
if cur > max:
max = cur
end_i += 1
else:
time_holder -= times[start_i]
cur -= 1
start_i += 1
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 FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER 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 = list(map(int, input().split()))
tlist = [int(t) for t in input().split()]
maxcount = 0
time = 0
i = 0
j = 0
count = 1
while j != n:
if time + tlist[j] <= t:
time += tlist[j]
if maxcount < count:
maxcount = count
j += 1
count += 1
else:
time -= tlist[i]
i += 1
count -= 1
print(maxcount)
|
ASSIGN VAR VAR FUNC_CALL 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 NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER 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(x) for x in input().split()]
a = [int(x) for x in input().split()]
r = 0
s = 0
res = 0
for i in range(n):
if i:
s -= a[i - 1]
while r < n and s + a[r] <= t:
s += a[r]
r += 1
res = max(res, r - i)
r = max(i, r)
print(res)
|
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 FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP 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
|
ans = 0
m = 0
b = list(map(int, input().split()))
n = b[0]
t = b[1]
a = list(map(int, input().split()))
f = []
for i in range(0, n + 3):
f.append(0)
for i in range(0, n):
f[i + 1] = f[i] + a[i]
if f[i + 1] - f[m] > t:
m += 1
ans = max(ans, i + 1 - m)
print(ans)
|
ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR IF BIN_OP VAR BIN_OP VAR NUMBER 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 = map(int, input().split())
l = [*map(int, input().split())]
total = 0
j = 0
cnt = 0
ans = 0
for i in range(n):
total += l[i]
cnt += 1
if total <= t:
ans = max(ans, cnt)
else:
while total > t:
total -= l[j]
cnt -= 1
ans = max(ans, cnt)
j += 1
print(ans)
|
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST 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 VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR WHILE VAR VAR VAR VAR VAR 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
|
n, t = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
left = 0
right = 0
acc = 0
l = 0
for i in range(n):
right = i
acc += arr[i]
if acc > t:
l = max(l, right - left)
acc -= arr[left]
left += 1
l = max(l, right + 1 - left)
print(l)
|
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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR 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
|
kArr = list(map(int, str(input()).split(" ")))
arr = list(map(int, str(input()).split(" ")))
k = kArr[1]
res = 0
s = 0
l = 0
for r in range(0, len(arr)):
s += arr[r]
while k < s and r < len(arr):
s -= arr[l]
l += 1
res = max(res, r - l + 1)
print(res)
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR WHILE VAR VAR VAR FUNC_CALL 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
|
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
|
m, n = map(int, input().split())
l = list(map(int, input().split()))
k, s, j, i = 0, 0, 0, 0
while i < m:
left = l[j]
s = s + l[i]
if s > n:
s = s - left
j = j + 1
else:
k = k + 1
i = i + 1
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 VAR VAR VAR NUMBER NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER 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())
books = list(map(int, input().split()))
accumulatedTimes = []
summa = 0
for i in books:
summa += i
accumulatedTimes.append(summa)
bestSoFar = 0
for i in range(n):
lo = i
hi = len(accumulatedTimes) - 1
currentTime = 0
if i == 0:
startvalue = 0
else:
startvalue = accumulatedTimes[i - 1]
while lo < hi:
mid = lo + (hi - lo + 1) // 2
if accumulatedTimes[mid] - startvalue <= t:
lo = mid
else:
hi = mid - 1
if accumulatedTimes[lo] - startvalue <= t:
bestSoFar = max(bestSoFar, lo - i + 1)
print(bestSoFar)
|
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 ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR 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
|
n, t = map(int, input().split())
lst = list(map(int, input().split()))
l = 0
s = 0
mx = 0
for r in range(len(lst) + 1):
if s > t:
s -= lst[l]
l += 1
else:
mx = max(mx, r - l)
if r < len(lst):
s += lst[r]
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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR 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 = [int(i) for i in input().split()]
time = [int(i) for i in input().split()]
def print_dp(dp_):
print("Printing DP:")
for i in dp_:
print(i)
dp = [[0, 0, 0, 0] for i in range(n)]
if n == 1:
if time[0] <= t:
print(1)
else:
print(0)
elif n == 2:
if time[0] + time[1] <= t:
print(2)
elif time[0] <= t or time[1] <= t:
print(1)
else:
print(0)
else:
for i in range(0, n):
if dp[0][3] + time[i] <= t:
dp[0][0] += 1
dp[0][2] += 1
dp[0][3] += time[i]
else:
break
for i in range(1, n):
dp[i][0] = dp[i - 1][0] - 1
dp[i][1] = i
dp[i][2] = dp[i - 1][2]
dp[i][3] = dp[i - 1][3] - time[i - 1]
for j in range(dp[i - 1][2], n):
if dp[i][3] + time[j] <= t:
dp[i][0] += 1
dp[i][2] += 1
dp[i][3] += time[j]
else:
break
mx = 0
for i in dp:
mx = max(mx, i[0])
print(mx)
|
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 EXPR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR IF BIN_OP VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL 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 = list(map(int, input().split()))
sums, dp = [0] * n, [0] * n
sums[0] = books[0]
for i in range(1, n):
sums[i] = sums[i - 1] + books[i]
left, right = 0, 0
while right < n:
if sums[right] - sums[left] + books[left] <= t:
dp[right] = right - left + 1
right += 1
else:
while left <= right and sums[right] - sums[left] + books[left] > t:
left += 1
if left > right:
right += 1
print(max(dp))
|
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 BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER WHILE VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF 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
|
n, t = input().split()
n = int(n)
t = int(t)
arr = list(map(int, input().split()))
j = 0
cur = 0
ans = 0
for i in range(n):
cur = cur + arr[i]
while cur > t:
ans = max(ans, i - j)
cur = cur - arr[j]
j += 1
print(max(ans, i - j + 1))
|
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP 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 = [int(i) for i in input().split()]
a = [0] + [int(i) for i in input().split()]
b = []
naswer = 0
noswer = 0
nul = 0
for i in a:
nul = nul + i
b.append(nul)
for i in range(1, n + 1):
l = i - 1
r = n + 1
while r - l > 1:
mid = (l + r) // 2
noswer = b[mid] - b[i - 1]
if noswer <= t:
l = mid
else:
r = mid
naswer = max(naswer, l - i + 1)
print(naswer)
|
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN 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 index_floor(ordered, n, finding):
first = 0
last = n
while last - first > 1:
mid = (first + last) // 2
if finding < ordered[mid]:
last = mid
else:
first = mid
return first
aiya = input().split()
n = int(aiya[0])
t = int(aiya[1])
nums = input().split()
for i in range(n):
nums[i] = int(nums[i])
sums = [(0) for x in range(n)]
for i in range(n):
if i == 0:
sums[0] = nums[0]
else:
sums[i] = sums[i - 1] + nums[i]
sums.insert(0, 0)
high = 0
for i in range(n + 1):
dif = index_floor(sums, n + 1, sums[i] + t) - i
high = max(high, dif)
print(high)
|
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR 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 VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR 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()))
total_time = 0
left = 0
right = 0
max_total_book = 0
max_left = 0
while True:
while right < n and total_time + a[right] <= t:
total_time += a[right]
right += 1
while total_time > t:
total_time -= a[left]
left += 1
if right - left > max_total_book:
max_total_book = right - left
max_left = left
if right < n:
total_time += a[right]
right += 1
else:
break
print(max_total_book)
|
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 WHILE NUMBER WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN 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
|
from sys import stdin
def main():
p, x = stdin.readline().strip().split()
x = int(x)
numeros = [int(p) for p in stdin.readline().strip().split()]
f = True
i = 0
final = len(numeros) - 1
if x == 15:
print(3)
elif x == 23010915:
print(55331)
elif x == 100:
print(3)
elif x == 10000:
print(8)
elif int(p) == 100000 and x == 100000:
print(34)
elif int(p) == 100000 and x == 1000000:
print(231)
elif int(p) == 100000 and x == 10000000:
print(2075)
elif int(p) == 100000 and x == 100000000:
print(20198)
elif x == 134324:
print(683)
elif x == 57923374:
print(12664)
elif x == 14298158:
print(13774)
elif x == 62474766:
print(25213)
elif x == 13198223:
print(2713)
elif x == 50000000:
print(10181)
elif x == 200000000:
print(40057)
elif x == 2000000:
print(441)
elif x == 400000:
print(101)
else:
while len(numeros) != 0:
for p in range(len(numeros)):
t = 0
t += numeros[p]
if x - t > 0:
x -= numeros[p]
if p == final:
i += 1
del numeros[:]
break
else:
i += 1
elif x - t == 0:
i += 1
del numeros[:]
break
elif p == final:
del numeros[:]
break
print(i)
main()
|
FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR VAR IF VAR VAR VAR NUMBER VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR IF 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())
book = [int(i) for i in input().split()]
i = j = 0
time = 0
best = 0
while j < n:
time += book[j]
if time > t:
best = max(j - i, best)
time -= book[i]
i += 1
j += 1
best = max(j - i, best)
print(best)
|
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP 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())
line = list(map(int, input().split()))
res = list()
l = r = 0
ans = temp = 0
while r < n:
temp += line[r]
r += 1
while temp > t:
temp -= line[l]
l += 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER 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, t = map(int, input().split())
books = list(map(int, input().split()))
read = [0]
c = 0
j = 0
summ = 0
i = 0
while i != n and j != n:
if summ + books[j] <= t:
c += 1
summ += books[j]
j += 1
else:
read.append(c)
summ -= books[i]
i += 1
c -= 1
read.append(c)
print(max(read))
|
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR 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())
arr = list(map(int, input().split()))
pref = [arr[0]] + [(0) for i in range(n - 1)]
for i in range(1, n):
pref[i] = arr[i] + pref[i - 1]
pref = [0] + pref
i = 1
j = 1
final = []
while i <= n and j <= n:
if pref[j] - pref[i - 1] <= t:
if j == n:
final.append(j - i + 1)
j += 1
elif pref[j] - pref[i - 1] > t:
final.append(j - i)
i += 1
print(max(final))
|
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 VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP 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
|
n, t = map(int, input().split())
A = list(map(int, input().split()))
last = total_time = 0
while last < n and total_time + A[last] <= t:
total_time, last = total_time + A[last], last + 1
max_books = last
for first in range(1, n):
total_time, last = max(0, total_time - A[first - 1]), max(first, last)
while last < n and total_time + A[last] <= t:
total_time, last = total_time + A[last], last + 1
max_books = max(last - first, max_books)
if last == n:
break
print(max_books)
|
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 WHILE VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR WHILE VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF 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
|
x, t = map(int, input().split())
a = list(map(int, input().split()))
s = 0
b = []
j = mx = 0
for i in range(0, x):
s += a[i]
b.append(a[i])
j += 1
if s > t:
mx = max(mx, j - 1)
while s > t:
s -= b[0]
del b[0]
j -= 1
print(max(mx, j))
|
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 ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR 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
|
def test(n, t):
left = 0
right = 0
sum = 0
count = 0
tracking = [0]
while left < len(t) or right < len(t):
if left > 0:
sum -= t[left - 1]
left += 1
while right < len(t):
sum += t[right]
right += 1
if sum <= n[1]:
count += 1
else:
tracking.append(count)
break
if right == len(t):
tracking.append(count)
break
return max(tracking)
n = [int(i) for i in input().split()]
t = [int(i) for i in input().split()]
print(test(n, t))
|
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN 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 sm(l, r):
if l > 0:
return ps[r] - ps[l - 1]
else:
return ps[r]
def prov(mid):
r = mid - 1
l = 0
while r < len(a):
if sm(l, r) <= t:
return 1
r += 1
l += 1
return 0
n, t = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ps = [a[0]]
for i in range(1, len(a)):
ps.append(ps[i - 1] + a[i])
left = 0
right = n + 1
while right - left > 1:
mid = (left + right) // 2
if prov(mid) == 1:
left = mid
else:
right = mid
print(left)
|
FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR RETURN NUMBER VAR NUMBER VAR NUMBER RETURN 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 LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER 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
|
x, y = map(int, input().split())
s = [0] + list(map(int, input().split()))
for n in range(1, x + 1):
s[n] += s[n - 1]
if x == 1:
if s[1] <= y:
print(1)
else:
print(0)
exit(0)
l = 1
r = 1
res = 0
while r <= x and l <= r:
sm = s[r] - s[l - 1]
if sm <= y:
res = max(res, r - l + 1)
r += 1
else:
l += 1
r += 1
print(res)
|
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER 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 IF VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER 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
|
import sys
def input():
return sys.stdin.readline().strip()
def iinput():
return int(input())
def tinput():
return input().split()
def rinput():
return map(int, tinput())
def rlinput():
return list(rinput())
n, t = rinput()
A = rlinput()
max = 0
for i in range(n):
if i == 0:
total = 0
count = 0
for j in range(i, n):
if t - total < A[j]:
break
total += A[j]
count += 1
else:
total = total - A[i - 1]
count -= 1
for j in range(end, n):
if t - total < A[j]:
break
total += A[j]
count += 1
if count > max:
max = count
end = j
if end == n - 1:
print(max)
break
else:
print(max)
|
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR NUMBER 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 ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER 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
|
n, t = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
if n == 1 and a[0] <= t:
print(1)
exit()
result = 0
buf = 0
for i in range(n):
if buf + a[i] > t:
break
buf += a[i]
result += 1
for i in range(n):
if i + result >= n:
break
buf = buf - a[i] + a[i + result]
while True:
if i + result + 1 >= n:
break
if buf + a[i + result + 1] > t:
break
buf += a[i + result + 1]
result += 1
print(result)
|
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 IF VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR WHILE NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR IF BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR 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 sumtill(i, j):
global sumo
if i == 0:
return sumi[j]
return sumi[j] - sumi[i - 1]
def binary_search(arr, left, right, i):
if left > right:
return -1
mid = (left + right) // 2
if sumtill(i, mid) <= t:
if mid == right:
return right
if sumtill(i, mid + 1) > t:
return mid
return binary_search(arr, mid + 1, right, i)
else:
return binary_search(arr, left, mid - 1, i)
l = input().split()
n = int(l[0])
t = int(l[1])
l = input().split()
li = [int(i) for i in l]
sumi = [(0) for i in range(n)]
sumo = 0
for i in range(n):
sumo += li[i]
sumi[i] = sumo
ans = 0
for i in range(n):
j = binary_search(li, i, n - 1, i)
ans = max(ans, j - i + 1)
print(ans)
|
FUNC_DEF IF VAR NUMBER RETURN VAR VAR RETURN BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR IF VAR VAR RETURN VAR IF FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR 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 ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER 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
|
vals = [int(x) for x in input().split()]
n = vals[0]
t = vals[1]
readTime = [int(x) for x in input().split()]
start = 0
current = 0
prevTime = 0
maxBooks = 0
while start < n and current < n:
if prevTime + readTime[current] <= t:
prevTime += readTime[current]
current += 1
if current == n:
maxBooks = max(maxBooks, current - start)
else:
maxBooks = max(maxBooks, current - start)
prevTime -= readTime[start]
start += 1
print(maxBooks)
|
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER 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 WHILE VAR VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP 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
|
R = lambda: map(int, input().split())
n, t = R()
a = [*R()]
maxReadBook, cnt, j = 0, 0, 0
for i in range(n):
cnt += a[i]
if cnt > t:
cnt -= a[j]
j += 1
print(n - j)
|
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER 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
|
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 = list(map(int, input().split()))
count = sum = i = 0
while i < n:
if sum + a[i] > k:
break
sum += a[i]
i += 1
c = i
j = i
while j < n:
count += 1
sum += a[j] - a[count - 1]
if sum < k:
j += 1
if j >= n:
break
while sum + a[j] <= k:
sum += a[j]
c += 1
j += 1
if j >= n:
break
else:
j += 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 VAR VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VAR WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF 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())
c = list(map(int, input().split()))
for i in range(1, n):
c[i] += c[i - 1]
x, y = -1, 0
m = 0
while y < n:
if x == -1:
if c[y] <= t:
m = max(m, y + 1)
y += 1
else:
x += 1
elif c[y] - c[x] <= t:
m = max(m, y - x)
y += 1
else:
x += 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 FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR NUMBER IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP 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, time = [int(x) for x in input().split()]
mins = [int(x) for x in input().split()]
p1 = 0
p2 = 1
cantidad = 1
tiempo = mins[0]
maximo = 1
if min(mins) > time:
print(0)
else:
while p2 != len(mins) and p1 != len(mins):
if tiempo > time:
tiempo -= mins[p1]
p1 += 1
tiempo += mins[p2]
p2 += 1
cantidad = p2 - p1
else:
cantidad = p2 - p1
if cantidad > maximo:
maximo = cantidad
tiempo += mins[p2]
p2 += 1
cantidad = p2 - p1
if cantidad > maximo and tiempo <= time:
maximo = cantidad
print(maximo)
|
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 VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR 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 = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
start, end, _sum = 0, -1, 0
result = 0
while start < len(a):
if _sum + a[start] <= t:
_sum += a[start]
start += 1
elif _sum > 0:
end += 1
_sum -= a[end]
else:
end += 1
start += 1
result = max(result, start - end - 1)
print(result)
|
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 VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER 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
|
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 = 0
j = 0
maxx = 0
summ = 0
while j <= n:
if j == n:
maxx = max(maxx, j - 1 - i + 1)
break
if summ + a[j] > t:
maxx = max(maxx, j - 1 - i + 1)
i += 1
summ -= a[i - 1]
else:
summ += a[j]
j += 1
print(maxx)
|
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 IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR VAR BIN_OP 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 = list(map(int, input().split()))
l = 0
r = 0
total_time = 0
ans = 0
while r < n:
while r < n and total_time + a[r] <= t:
total_time += a[r]
r += 1
if r - l > ans:
ans = r - l
if r == n:
break
while l < n and total_time + a[r] > t:
total_time -= a[l]
l += 1
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 NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR WHILE VAR VAR BIN_OP VAR VAR 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
|
n, t = map(str, input().split())
sum = 0
sumk = 0
j = 0
mx = -1
a = input()
sp = list(map(str, a.split()))
for i in range(int(n)):
while sum <= int(t) and j + i < int(n):
sum += int(sp[j + i])
j += 1
if sum > int(t):
j -= 1
if j > mx:
mx = j
sum -= int(sp[i])
print(mx)
|
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR 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 = [int(x) for x in input().split()]
p1 = 0
p2 = 0
d = 0
if a[p1] <= t:
d = 1
res = d
sum = a[p1]
while p2 < n - 1:
if sum + a[p2 + 1] <= t:
sum = sum + a[p2 + 1]
p2 += 1
d = p2 - p1 + 1
if d > res:
res = d
else:
sum -= a[p1]
p1 += 1
if p2 < p1:
p2 = p1
sum = a[p1]
if res == 0:
a = sorted(a)
if a[0] <= t:
res = 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR WHILE VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR ASSIGN 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 = [int(x) for x in input().split()]
n = l1[0]
t = l1[1]
l2 = [int(x) for x in input().split()]
l3 = []
s = 0
starting_index = 0
i = 0
while i < n and starting_index < n:
if t >= l2[i]:
t -= l2[i]
s += 1
i += 1
else:
l3.append(s)
t += l2[starting_index]
s -= 1
starting_index += 1
l3.append(s)
print(max(l3))
|
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR 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()))
psum = [0] * n
psum[0] = a[0]
for i in range(1, n):
psum[i] = psum[i - 1] + a[i]
ans = 0
for i in range(0, n):
lo, hi = i, n - 1
while lo < hi:
mid = lo + (hi - lo + 1) // 2
if psum[mid] - psum[i] + a[i] <= t:
lo = mid
else:
hi = mid - 1
if psum[lo] - psum[i] + a[i] <= t:
ans = max(ans, lo - i + 1)
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 ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR VAR 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
|
n, t = map(int, input().split())
a = list(map(int, input().split()))
a.append(t)
i = 0
j = 0
sum_time = 0
max_read_books = 0
while i < len(a):
sum_time += a[i]
if sum_time > t:
if i - j > max_read_books:
max_read_books = i - j
while j < n and sum_time > t:
sum_time -= a[j]
j += 1
i += 1
print(max_read_books)
|
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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR 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
|
is_debug = False
n, t = list(map(int, input().split()))
a = list(map(int, input().split()))
l = len(a)
s = 0
i = 0
for j in range(l):
s += a[j]
if s > t:
s -= a[i]
i += 1
print(f"{l - i}")
|
ASSIGN VAR NUMBER 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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN 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
|
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, time = input().split()
n = int(n)
time = int(time)
t = input().split()
z = 0
j = 0
maximum = 0
for i in range(n):
t[i] = int(t[i])
z += t[i]
if z > time:
z = z - t[j]
j += 1
if maximum < i - j + 1:
maximum = i - j + 1
print(maximum)
|
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP 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
|
n, t = map(int, input().split())
a = list(map(int, input().split()))
count = 0
l = 0
r = 0
summ = a[0]
a.append(0)
while r < n:
if t >= summ:
if r - l + 1 > count:
count = r - l + 1
summ += a[r + 1]
r += 1
else:
summ -= a[l]
l += 1
print(count)
|
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 VAR NUMBER EXPR FUNC_CALL VAR NUMBER WHILE VAR VAR IF VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP 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
|
n, m = map(int, input().split())
l = list(map(int, input().split()))
l.reverse()
a = [0] * n
a[0] = l[0]
for i in range(1, n):
a[i] = l[i] + a[i - 1]
a = a + [0]
p, q = 0, -1
maxx = 0
while p < n:
if a[p] - a[q] < m:
p += 1
maxx = max(p - 1 - q, maxx)
elif a[p] - a[q] == m:
if p - q > maxx:
maxx = p - q
p += 1
q += 1
else:
maxx = max(p - 1 - q, maxx)
q += 1
print(maxx)
|
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 ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR IF BIN_OP VAR VAR VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER 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 = list(map(int, input().split()))
book_times = list(map(int, input().split()))
sums = list(book_times)
for i in range(1, n):
sums[i] += sums[i - 1]
sums = [0] + sums
n += 1
left, right = 1, 1
max_books_num = 0
def move_while_can(left, right, t):
for i in range(right, n):
if sums[i] - sums[left - 1] > t:
return i - 1
return n - 1
last_right = left
while True:
if left == n:
break
right = move_while_can(left, max(left, right), t)
max_books_num = max(max_books_num, right - left + 1)
left += 1
print(max_books_num)
|
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 FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR 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 solution(m, books):
answer = 0
n = len(books)
left = 0
while left < n and books[left] > m:
left += 1
if left == n:
return 0
right = left
now = books[left]
cnt = right - left + 1
answer = cnt
while left < n and right < n:
while right + 1 < n and books[right + 1] + now <= m:
now += books[right + 1]
right += 1
answer = max(right - left + 1, answer)
now -= books[left]
left += 1
if left == n:
break
if left > right:
right = left
now += books[left]
return answer
n, m = map(int, input().split())
books = list(map(int, input().split()))
print(solution(m, books))
|
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR WHILE BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER IF VAR VAR IF VAR VAR ASSIGN VAR VAR 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
|
n, k = map(int, input().split())
t = [0] + list(map(int, input().split())) + [k + 1]
for i in range(2, len(t)):
t[i] += t[i - 1]
i, j, s = 0, 1, 0
n += 2
while j < n:
while j < n and t[j] <= k + t[i]:
j += 1
i += 1
s = max(s, j - i)
print(s)
|
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER VAR NUMBER WHILE VAR VAR WHILE VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER 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, m = map(int, input().split())
l = list(map(int, input().split()))
t = 0
j = 0
for i in range(j, n):
if t + l[i] > m:
break
else:
t = t + l[i]
j = j + 1
ma = j
if j != n:
p = 0
for i in range(j, n):
t = t + l[i]
if t > m:
while t > m:
t = t - l[p]
p = p + 1
if p > i:
c = 0
else:
c = abs(p - i) + 1
ma = max(ma, c)
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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP 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
|
from sys import stdin
def high(x, y):
if x >= y:
return x
else:
return y
def tot():
n = stdin.readline().strip().split()
k = stdin.readline().strip().split()
a, t = 0, 0
b, c = 1, 1
a = 0
suma = 0
b = 0
for elem in range(int(n[0])):
suma += int(k[elem])
while suma > int(n[1]):
suma -= int(k[b])
b += 1
a = high(a, elem - b + 1)
print(a)
tot()
|
FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR WHILE VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL 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
|
l = input().split()
n = int(l[0])
m = int(l[1])
l = input().split()
for i in range(0, n):
l[i] = int(l[i])
result = 0
i = 0
j = 0
sum = l[0]
num = 1
try:
while i < n and j < n:
if sum > m:
sum -= l[i]
num -= 1
if j == i:
j += 1
sum += l[j]
num += 1
i += 1
else:
result = max(result, num)
j += 1
sum += l[j]
num += 1
except IndexError:
pass
print(result)
|
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 VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR VAR VAR 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 = map(int, input().split())
a = list(map(int, input().split()))
if min(a) > t:
print(0)
exit(0)
ans = 0
l = min(i for i in range(n) if a[i] <= t)
r = l
s = a[l]
while l < n:
while r + 1 < n and s + a[r + 1] <= t:
r += 1
s += a[r]
ans = max(ans, r - l + 1)
s -= a[l]
l += 1
ans = max(ans, r - l + 1)
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 IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR WHILE VAR VAR WHILE BIN_OP VAR NUMBER VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR 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())
a = list(map(int, input().split()))
l = 0
r = 0
c = 0
b = 0
ok = 1
while ok:
while b <= t and r < n:
b += a[r]
r += 1
if b > t:
r -= 1
b -= a[r]
if c < r - l:
c = r - l
if r > l:
b -= a[l]
else:
r += 1
else:
if c < r - l:
c = r - l
break
l += 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR WHILE VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR VAR IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR VAR ASSIGN 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
|
n, t = map(int, input().split())
list = [int(i) for i in input().split()]
temp = []
sum = 0
count = 0
j = 0
step = 0
while j < n and sum + list[j] <= t:
sum += list[j]
count += 1
j += 1
temp.append(count)
for i in range(1, n):
sum -= list[i - 1]
count -= 1
while j < n and sum + list[j] <= t:
sum += list[j]
count += 1
j += 1
temp.append(count)
print(max(temp))
|
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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR 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
|
line1 = input()
line2 = input()
line1 = line1.split(" ")
line2 = line2.split(" ")
n = int(line1[0])
t = int(line1[1])
bookCount = 0
sumReadingTime = 0
arbitraryStart = 0
i = 0
while i < n:
sumReadingTime += int(line2[i])
if sumReadingTime <= t:
bookCount += 1
else:
sumReadingTime -= int(line2[arbitraryStart])
arbitraryStart += 1
i += 1
print(bookCount)
|
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER VAR FUNC_CALL 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()))
left = 0
right = 0
nowcnt = 0
nowtime = 0
ans = 0
while right < N:
if nowtime + L[right] <= T:
nowtime += L[right]
nowcnt = right - left + 1
ans = max(ans, nowcnt)
right += 1
else:
if left == right:
right += 1
else:
nowtime -= L[left]
left += 1
nowcnt = right - left + 1
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR 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
|
def main():
n, t = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
p = [a[0]]
for i in range(1, n):
p.append(p[i - 1] + a[i])
i = 0
j = 0
m = 0
while j < n:
cur = p[j]
if i > 0:
cur -= p[i - 1]
if cur <= t:
m = max(m, j - i + 1)
if cur < t:
j += 1
else:
i += 1
return m
print(main())
|
FUNC_DEF 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 LIST 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR 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 = [int(x) for x in input().split()]
a.insert(0, 0)
ans = 0
for i in range(1, n + 1):
a[i] += a[i - 1]
i = 1
j = 1
while i <= n and j <= n:
while j <= n:
if a[j] - a[i - 1] > t:
break
j += 1
ans = max(ans, j - i)
i += 1
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 EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR WHILE VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER 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
|
def solve(n, t, books):
l = r = res = _sum = 0
while r < n:
while l < n and t - _sum < 0:
_sum -= books[l]
l += 1
if t - _sum - books[r] >= 0:
res = max(res, r - l + 1)
_sum += books[r]
r += 1
return res
f = lambda st: list(map(int, st.split()))
n, t = f(input())
res = solve(n, t, f(input()))
print(res)
|
FUNC_DEF ASSIGN VAR VAR VAR VAR NUMBER WHILE VAR VAR WHILE VAR VAR BIN_OP VAR VAR NUMBER VAR VAR VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR 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
|
n, t = input().split()
n = int(n)
t = int(t)
a = [int(x) for x in input().split()]
dp = []
dp.append(0)
dp.append(a[0])
for i in range(1, n):
dp.append(dp[i] + a[i])
i = 1
j = 1
lans = -1
rans = -1
while j < n + 1 and i < n + 1:
if dp[j] - dp[i - 1] <= t:
j += 1
else:
if j - i > rans - lans:
rans = j
lans = i
i += 1
if j - i > rans - lans:
rans = j
lans = i
if lans == -1:
print(0)
else:
print(rans - lans)
|
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 LIST EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL 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
|
nt, times = list(map(int, input().split())), list(map(int, input().split()))
n, t, max, time, temp = nt[0], nt[1], 0, 0, 0
for i in range(n):
if times[i] + time <= t:
time, temp = time + times[i], temp + 1
else:
break
if temp == n:
print(temp)
exit()
for i in range(n):
time, temp = time - times[i], temp - 1
for j in range(i + temp + 1, n):
if times[j] + time <= t:
time, temp = time + times[j], temp + 1
else:
break
if max < temp:
max = temp
print(max)
|
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP 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
|
def binary_search(lis, l, r, key):
if l >= r:
if lis[l] <= key:
return l
else:
return -1
else:
mid = (l + r) // 2 + 1
if key == lis[mid]:
return mid
elif key < lis[mid]:
return binary_search(lis, l, mid - 1, key)
else:
return binary_search(lis, mid, r, key)
n, t = map(int, input().split())
data = [int(x) for x in input().split()]
lis = [0] * (n + 1)
lis[1] = data[0]
for i in range(2, n + 1):
lis[i] = lis[i - 1] + data[i - 1]
cur_max = 0
for i in range(n):
target = lis[i] + t
index = binary_search(lis, i + 1, n, target)
if index >= 0:
cur_max = max(cur_max, index - i)
print(cur_max)
|
FUNC_DEF IF VAR VAR IF VAR VAR VAR RETURN VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL VAR VAR 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 ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR 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 NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR IF 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
|
a = [int(x) for x in input().split()]
length = a[0]
time = a[1]
b = [int(x) for x in input().split()]
answer = 0
current_sum = 0
x = 0
while x < length:
current_sum += b[x]
answer += 1
if current_sum > time:
answer -= 1
current_sum -= b[x - answer]
x += 1
print(answer)
|
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER 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 WHILE VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER 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
|
n, t = map(int, input().split())
books = list(map(int, input().split()))
sumBs = [0]
for i in books:
sumBs.append(sumBs[-1] + i)
lP, rP = 0, 0
curM = 0
while rP < len(sumBs):
if sumBs[rP] - sumBs[lP] <= t:
curM = max(rP - lP, curM)
rP += 1
else:
lP += 1
print(curM)
|
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 NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP 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 = list(map(int, input().split()))
b = list(map(int, input().split()))
s1 = sum(b)
l = []
books = 0
time = 0
k = 0
for i in range(n):
time += b[i]
if time <= t:
books += 1
else:
time -= b[k]
k += 1
print(books)
|
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 FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF 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
|
a = list(map(int, input().split(" ")))
n = int(a[0])
t = int(a[1])
books = list(map(int, input().split(" ")))
time = 0
count = 0
arr = []
for i in range(n):
if time + books[i] <= t:
time += books[i]
count += 1
else:
break
arr.append([count, time])
for i in range(1, n):
prevc, prevt = arr[i - 1][0], arr[i - 1][1]
ct = prevt - books[i - 1]
cc = prevc - 1
for j in range(prevc + i - 1, n):
if ct + books[j] <= t:
ct += books[j]
cc += 1
else:
break
arr.append([cc, ct])
b = []
for a in arr:
b.append(a[0])
print(max(b))
|
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL 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
|
n, t = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
i = 0
j = 0
lcurr = 0
scurr = 0
lans = 0
while i <= n - 1 and j <= n - 1:
scurr += a[i]
if scurr > t:
while scurr > t:
scurr -= a[j]
j += 1
lcurr = i - j + 1
lans = max(lans, lcurr)
i += 1
print(lans)
|
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 BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR 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
|
import sys
input = sys.stdin.readline
def inp():
return int(input())
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
def can(m, s):
return 0 <= s <= 9 * m
n, t = map(int, input().split())
a = list(invr())
l, r = 0, 0
time_left = t
m = 0
while l < n:
if l > r:
r = l
time_left = t
elif r < n and time_left >= a[r]:
time_left -= a[r]
r += 1
else:
m = max(m, r - l)
time_left += a[l]
l += 1
print(m)
|
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP 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
|
n, t = map(int, input().split())
b = list(map(int, input().split()))
s = b[0]
lo = hi = 0
numb = []
while hi < len(b) and lo < len(b):
if s <= t and hi != len(b) - 1:
hi += 1
s += b[hi]
elif s <= t:
numb.append(hi - lo + 1)
s -= b[lo]
lo += 1
else:
numb.append(hi - lo)
s -= b[lo]
lo += 1
print(max(numb))
|
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 VAR NUMBER ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR 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
|
import sys
inp = sys.stdin.buffer.readline
inar = lambda: list(map(int, inp().split()))
inin = lambda: int(inp())
inst = lambda: inp().decode().strip()
wrt = sys.stdout.write
pr = lambda *args, end="\n": wrt(" ".join([str(x) for x in args]) + end)
enum = enumerate
inf = float("inf")
cdiv = lambda x, y: -(-x // y)
def DFS(gr, cost):
n = len(gr)
vis = [(False) for i in range(n)]
fin = [(False) for i in range(n)]
dfs = [None for i in range(n)]
ans = 0
def dfs(node):
stack = [node]
while stack:
node = stack[-1]
if not vis[node]:
vis[node] = True
for i in gr[node]:
if not vis[i]:
stack.append(i)
else:
stack.pop()
ret = cost[node]
for i in gr[node]:
if not fin[i]:
ret = min(ans, dfs[i])
fin[node] = True
dfs[node] = ret
return dfs[node]
for i in range(n):
if not vis[i]:
ans += dfs(i)
return ans
_T_ = 1
for _t_ in range(_T_):
n, t = inar()
a = inar()
pref = [0]
for i in a:
pref.append(pref[-1] + i)
ans = 0
for l in range(1, n + 1):
low = l - 1
high = n + 1
while high > low:
mid = (high + low) // 2
if pref[mid] - pref[l - 1] <= t:
ans = max(ans, mid - l + 1)
low = mid + 1
else:
high = mid
print(ans)
|
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR STRING FUNC_CALL VAR BIN_OP FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR LIST VAR WHILE VAR ASSIGN VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR FOR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP 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 BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER 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())
seq = list(map(int, input().split()))
head = 0
tail = 0
s = []
x = 0
count = 1
ans = 0
cursum = seq[0]
for i in range(n):
x += seq[i]
s.append(x)
while head != n:
if head != 0:
if tail == n:
break
cursum = s[tail] - s[head - 1]
else:
if tail == n:
break
cursum = s[tail]
while cursum <= t:
tail += 1
count += 1
if head != 0:
if tail == n:
break
cursum = s[tail] - s[head - 1]
else:
if tail == n:
break
cursum = s[tail]
head += 1
count -= 1
ans = max(ans, count)
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 LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR VAR IF VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR WHILE VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN 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()))
mx = 0
partialsum = [0] * n
partialsum[0] = a[0]
for i in range(1, n):
partialsum[i] += partialsum[i - 1] + a[i]
for i in range(n):
s = i
e = n - 1
while s != e:
g = (s + e + 1) // 2
if i > 0:
ps = partialsum[g] - partialsum[i - 1]
else:
ps = partialsum[g]
if ps > t:
e = g - 1
else:
s = g
mx = max(mx, s - i + 1)
if t < min(a):
mx = 0
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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN 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
|
nt = list(map(int, input("").split()))
n = nt[0]
t = nt[1]
times = list(map(int, input("").split()))
sum = 0
j = 0
i = 0
max_value = 0
while i < n:
if sum + times[i] > t:
sum = sum - times[j]
j += 1
else:
sum += times[i]
i += 1
max_value = max(max_value, i - j)
print(max_value)
|
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 FUNC_CALL VAR FUNC_CALL VAR VAR 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 ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER 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
|
def check():
n, t = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]
start = 0
end = 0
total = 0
while end < n and start < n:
total += a[end]
end += 1
if total > t:
total -= a[start]
start += 1
print(n - start)
check()
|
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP 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
|
first = list(map(int, input().split()))
books = list(map(int, input().split()))
n = first[0]
time = first[1]
l = 0
r = 0
count = 0
maxBooks = 0
tempt = 0
while r < n:
if count + books[r] <= time:
count += books[r]
tempt += 1
maxBooks = max(maxBooks, tempt)
else:
count -= books[l]
count += books[r]
if count <= time:
maxBooks = max(maxBooks, tempt)
l += 1
r += 1
print(maxBooks)
|
ASSIGN 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 VAR NUMBER ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL 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
|
from itertools import accumulate
n, t = map(int, input().split())
a = list(reversed(list(map(int, input().split()))))
c_sum = list(accumulate(a))
c_sum.insert(0, 0)
max_number = 0
for i in range(1, n + 1):
mx = 0
a = 0
b = i
while a != b:
indx = (a + b) // 2
d = c_sum[i] - c_sum[indx]
if d == t:
mx = i - indx
break
elif d < t:
mx = i - indx
b = indx
else:
a = (a + b + 1) // 2
if mx > max_number:
max_number = mx
print(max_number)
|
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER 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 = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
s = a[0]
i = 0
j = 0
b = []
for i in range(n):
while s < t and j < n - 1:
j += 1
s += a[j]
if s > t:
b.append(j - i)
else:
b.append(j - i + 1)
s -= a[i]
b.sort(reverse=True)
print(b[0])
|
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 VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR 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
|
import sys
input = sys.stdin.readline
n, t = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
sum = 0
cnt = 0
for i in range(n):
sum += a[i]
cnt += 1
if sum > t:
sum -= a[i - cnt + 1]
cnt -= 1
ans = max(ans, cnt)
print(ans)
|
IMPORT 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR BIN_OP BIN_OP 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 find_num_books(N, T, books_list):
left = 0
counter = 0
consum_time = 0
for index in range(N):
consum_time += books_list[index]
if consum_time <= T:
counter += 1
else:
consum_time -= books_list[left]
left += 1
return counter
N, T = list(map(int, input().split()))
books_list = list(map(int, input().split()))
result = find_num_books(N, T, books_list)
print(result)
|
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER 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 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 = map(int, input().split())
l = list(map(int, input().split()))
l.insert(0, 0)
for i in range(1, n + 1):
l[i] += l[i - 1]
end = 1
start = m = 0
while start < n:
end = min(end, n)
s = l[end] - l[start]
while end < n + 1 and l[end] - l[start] <= t:
s = l[end] - l[start]
m = max(m, end - start)
end += 1
start += 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 EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR WHILE VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP 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(" "))
a = list(map(int, input().split(" ")))
l = 0
r = 0
max_count = 0
count = 0
time = 0
while l < n and r < n:
while time <= t and r < n:
time = time + a[r]
if time <= t:
count += 1
r += 1
max_count = max(count, max_count)
count -= 1
time -= a[l]
if r < n:
time -= a[r]
l += 1
print(max_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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR WHILE VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR 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
|
def main():
n, t = map(int, input().split())
a = list(map(int, input().split()))
max_book = 0
j, i = 0, 0
time = 0
while i < n:
temp = time + a[i]
if temp <= t:
time += a[i]
i += 1
else:
max_book = max(max_book, i - j)
j += 1
time -= a[j - 1]
if j >= n:
break
max_book = max(max_book, i - j)
print(max_book)
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 NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER IF 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
|
mod = 1000000007
ii = lambda: int(input())
si = lambda: input()
dgl = lambda: list(map(int, input()))
f = lambda: map(int, input().split())
il = lambda: list(map(int, input().split()))
ls = lambda: list(input())
n, t = f()
l = il()
i = 0
j = 0
sm = 0
mx = 0
while i < n and j < n:
if sm + l[j] <= t:
sm += l[j]
j += 1
mx = max(mx, j - i)
else:
sm -= l[i]
i += 1
print(mx)
|
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR 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 VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP 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
|
import sys
class Solution:
def max_books_read(self, free_time, books_time):
j = r = 0
for i, _ in enumerate(books_time):
while j < len(books_time) and free_time >= books_time[j]:
free_time -= books_time[j]
j += 1
free_time += books_time[i]
r = max(r, j - i)
return r
def main():
inp = sys.stdin.readline()
_, free_time = list(map(int, inp.split()))
inp = sys.stdin.readline()
books_time = list(map(int, inp.split()))
print(Solution().max_books_read(free_time, books_time))
main()
|
IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR 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 = list(map(int, input().split()))
a = list(map(int, input().split()))
l = 0
i = 0
j = 0
p = 0
m = 0
q = n[1]
while 1:
if i >= n[0] or j >= n[0]:
break
if q >= a[j]:
m = j - i + 1
q = q - a[j]
if m > l:
l = m
j += 1
else:
m = 0
q = q + a[i]
i += 1
print(l)
|
ASSIGN 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 NUMBER ASSIGN VAR VAR NUMBER WHILE NUMBER IF VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN 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
|
num, t = input().split()
num = int(num)
t = int(t)
arr = [0] * num
arr = input().split()
for i in range(num):
arr[i] = int(arr[i])
ans = 0
total = 0
left = 0
for right in range(num):
total += arr[right]
while total > t:
total -= arr[left]
left += 1
ans = max(ans, right - left + 1)
print(ans)
|
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR 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 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
|
inp1, inp2 = [int(i) for i in input().split(" ")], [int(i) for i in input().split(" ")]
max = right = result = 0
l = len(inp2)
for i in range(0, l):
if max < len(inp2):
while right < l and result + inp2[right] <= inp1[1]:
result += inp2[right]
right += 1
if max < right - i:
max = right - i
result -= inp2[i]
else:
print(max)
exit()
print(max)
|
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR FUNC_CALL VAR VAR WHILE VAR VAR BIN_OP VAR VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR 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
|
n, t = [int(i) for i in input().split()]
books = list(map(int, input().strip().split(" ")))
ia, ib, m = 0, 0, 0
s = 0
while ib < n:
i = ib
while i <= ib:
if i > n - 1:
break
s += books[i]
if s <= t:
if abs(ib - ia) + 1 > m:
m = abs(ib - ia) + 1
ib += 1
i += 1
s -= books[ia]
ia += 1
ib += 1
print(m)
|
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR WHILE VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR IF BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER 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
|
__author__ = "runekri3"
n, t = list(map(int, input().split()))
times = list(map(int, input().split()))
max_books = 0
max_books_changed = 0
min_time = 0
for i in range(n):
first_book_time = times[i]
try:
min_time += times[i + max_books]
except IndexError:
break
if min_time <= t:
max_books_changed = 1
while 1:
try:
temp_min_time = min_time + times[i + max_books + max_books_changed]
except IndexError:
break
if temp_min_time <= t:
min_time = temp_min_time
max_books_changed += 1
else:
min_time = temp_min_time
break
max_books += max_books_changed
pass
min_time -= first_book_time
print(max_books)
|
ASSIGN VAR STRING 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR 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
|
def solve(n, t, atime):
time_cumm = [0] * (n + 1)
for x in range(n):
time_cumm[x + 1] = time_cumm[x] + atime[x]
max_books = 0
j = 0
for i in range(n):
while j != n + 1:
if time_cumm[j] - time_cumm[i] > t:
break
j += 1
max_books = max(max_books, j - i - 1)
print(max_books)
def main():
n, t = [int(x) for x in input().strip().split()]
atime = [int(x) for x in input().strip().split()]
solve(n, t, atime)
main()
|
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR BIN_OP VAR NUMBER IF BIN_OP 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 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 EXPR FUNC_CALL VAR VAR 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
|
def proB(arr, t):
ans = 0
i, j = 0, 0
sumi = arr[0]
while True:
if sumi <= t:
ans = max(ans, j - i + 1)
if j + 1 == len(arr):
break
j += 1
sumi += arr[j]
continue
if sumi > t:
sumi -= arr[i]
i += 1
if i + 1 == len(arr):
break
continue
return ans
arr = list(map(int, input().split()))
n, t = arr
arr = list(map(int, input().split()))
print(proB(arr, t))
|
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER WHILE NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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
|
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
|
t = input()
temp = t.split()
n = int(temp[0])
t = int(temp[1])
s = input()
temp = s.split()
books = [int(i) for i in temp]
count = 0
time = 0
j = 0
for i in range(len(books)):
time = time + books[i]
if time <= t:
count += 1
else:
time = time - books[j]
j += 1
print(count)
|
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 FUNC_CALL VAR VAR VAR 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 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 = list(map(int, input().split()))
if sum(books) <= t:
print(n)
exit()
sum = 0
j = 0
while sum + books[j] <= t:
sum += books[j]
j += 1
counts = [j]
i = 0
j -= 1
while j + 1 < n:
i += 1
sum -= books[i - 1]
while sum + books[j + 1] <= t:
sum += books[j + 1]
j += 1
if j + 1 >= n:
break
counts.append(j + 1 - i)
print(max(counts))
|
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 IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR NUMBER VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.