description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | n, S = map(int, input().split())
arr = list(map(int, input().split()))
l, r = 0, n
ac = 0
while l < r:
k = l + r + 1 >> 1
at = [(x + (i + 1) * k) for i, x in enumerate(arr)]
at.sort()
cost = sum(at[:k])
if cost <= S:
l = k
ac = cost
else:
r = k - 1
print(l, ac) | 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 VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR EXPR FU... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def check(n, s, f):
a = []
for i in range(len(l)):
a.append(l[i] + n * (i + 1))
a.sort()
return sum(a[0:n]) <= s if f == 1 else sum(a[0:n])
n, s = map(int, input().split())
l = list(map(int, input().split()))
i = 0
while i <= n:
mid = (i + n) // 2
if check(mid, s, 1):
if i == m... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR RETURN VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL V... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def getcost(m):
summ = 0
global n
cost = [(0) for _ in range(n)]
for i in range(n):
cost[i] = m * (i + 1) + a[i]
cost.sort()
for i in range(m):
summ += cost[i]
return summ
n, s = map(int, input().split())
a = list(map(int, input().split()))
cost = [0] * n
summ = 0
for i in ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL 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 ... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def proverka(k, a, s):
b = []
for i in a:
b.append(i)
for i in range(len(b)):
b[i] = b[i] + k * (i + 1)
b.sort()
cnt = 0
index = 0
while cnt < k and s - b[index] >= 0:
cnt += 1
s -= b[index]
index += 1
if cnt < k:
return False
else:
... | FUNC_DEF ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER RETURN ... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def get(k, li):
a = [0] * len(li)
for i in range(len(li)):
a[i] = li[i] + (i + 1) * k
a.sort()
summ = 0
for i in range(k):
summ += a[i]
return summ
def b_search(n, li, k):
l = 0
h = n + 1
while h - l > 1:
m = (l + h) // 2
if get(m, li) <= k:
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR N... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | n, s = list(map(int, input().split()))
nums = list(map(int, input().split()))
def findcost(k):
prices = [(nums[i] + k * (i + 1)) for i in range(n)]
prices.sort()
return sum(prices[:k])
low, high = 0, n
ans, cos = 0, 0
while low <= high:
mid = (low + high) // 2
cost = findcost(mid)
if cost > ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER ... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | import sys
from itertools import accumulate
def solve():
def check(m):
if m == 0:
return 0
b = [(ai + (i + 1) * m) for i, ai in enumerate(a)]
b.sort()
return sum(b[:m])
n, S = map(int, input().split())
a = [int(i) for i in input().split()]
btm = -1
top... | IMPORT FUNC_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | import sys
input = sys.stdin.readline
def judge(x):
b = [(a[i] + (i + 1) * x) for i in range(n)]
b.sort()
s = sum(b[:x])
return s <= S
def binary_search():
l, r = 0, n
while l <= r:
mid = (l + r) // 2
if judge(mid):
l = mid + 1
else:
r = mid -... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | n, s = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = n + 1
while r - l > 1:
m = l + (r - l) // 2
B = A.copy()
for j in range(n):
B[j] = A[j] + (j + 1) * m
B.sort()
if sum(B[:m]) > s:
r = m
else:
l = m
B = A.copy()
for j in range(n):
B[j] = A[... | 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 VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def f(k):
cur = sum(sorted([(a[i] + (i + 1) * k) for i in range(n)])[:k])
return cur, cur <= S
read = lambda: map(int, input().split())
n, S = read()
a = list(read())
l, r = 0, n + 1
while r - l > 1:
m = l + r >> 1
if f(m)[1]:
l = m
else:
r = m
print(l, f(l)[0]) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR N... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | from sys import stderr, stdin
def readInts():
return map(int, stdin.readline().strip().split())
def print_err(*args, **kwargs):
print(*args, file=stderr, **kwargs)
def best_souvenirs(n, s, ns):
def attemptf(k):
ns2 = []
for i, v in enumerate(ns):
ns2.append(ns[i] + (i + 1)... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR VAR VAR VAR FUNC_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR RETURN NONE RETURN VAR... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def calc(cnt):
return sum(sorted(num + cnt * ind for ind, num in enumerate(price, 1))[:cnt])
n, money = map(int, input().split())
price = [int(num) for num in input().split()]
can = 0
cant = n + 1
while cant - can > 1:
mid = (can + cant) // 2
if calc(mid) <= money:
can = mid
else:
cant... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER 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 NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def ispossible(a, k):
l = [0] * len(a)
for i in range(len(a)):
l[i] = a[i] + (i + 1) * k
l.sort()
return sum(l[:k])
n, S = map(int, input().split())
a = list(map(int, input().split()))
nn = [int(i) for i in range(1, n + 1)]
l, h = 0, n + 1
while h - l > 1:
m = (l + h) // 2
if ispossibl... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR RETURN FUNC_CALL VAR 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_C... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def main():
n, s = map(int, input().split())
a = [int(i) for i in input().split()]
l, r = 0, n
while r - l > 1:
mid = (l + r) // 2
subarr = [(0) for _ in range(n)]
for i in range(n):
subarr[i] = a[i] + (i + 1) * mid
subarr.sort()
pref = 0
for i... | FUNC_DEF 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 VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP ... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | from sys import stdin
def cost_of(data, k):
kl = []
for index, item in enumerate(data):
kl.append(item + (index + 1) * k)
kl.sort()
accu = 0
for i in range(0, k):
accu += kl[i]
return accu
n, s = map(int, stdin.readline().rstrip().split())
data = list(map(int, stdin.readline(... | FUNC_DEF ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUN... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | vals = input().split()
n = int(vals[0])
S = int(vals[1])
a = [int(v) for v in input().split()]
answer1 = 0
answer2 = 0
left = 0
right = n - 1
while left <= right:
mid = (left + right) // 2
c = [(x + (index + 1) * (mid + 1)) for index, x in enumerate(a)]
c.sort()
s = sum(c[: mid + 1])
if s == S:
... | 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 VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP V... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def check(x, a, u):
s = 0
a.sort(key=lambda o: o[0] + o[1] * x)
for i in range(0, x):
s += a[i][0] + a[i][1] * x
if s > u:
return [False]
return [True, s]
def binary_search(a, n):
l = 0
r = len(a)
while r - l > 1:
m = (r + l) // 2
if a[m] > n:
... | FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR IF VAR VAR RETURN LIST NUMBER RETURN LIST NUMBER VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR B... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | n, S = map(int, input().split())
st = input().split(" ")
cost = [int(num) for num in st]
l, r, Smin, k = 0, n + 1, 0, 0
for _ in range(20):
k = int((l + r) / 2)
a = list()
for i in range(n):
a.append(cost[i] + k * (i + 1))
a.sort()
s = 0
for i in range(k):
s += a[i]
if s <= S... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_C... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def binarySearch(k, x, ls):
l = 0
r = k
while l <= r:
mid = (l + r) // 2
b = price(mid, ls)
if b == x:
return mid
elif b < x:
l = mid + 1
else:
r = mid - 1
return l - 1
def price(k, ls):
ar = []
for i in range(len(ls))... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR RETURN VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | n, S = map(int, input().split())
a = list(map(int, input().split()))
def calc(k):
m = [(a[i] + k * (i + 1)) for i in range(n)]
m = sorted(m)
return sum(m[:k]) <= S, sum(m[:k])
l = 0
r = n
while l < r:
mid = (l + r + 1) // 2
f, s = calc(mid)
if f:
l = mid
else:
r = mid - 1... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN V... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def f(arr, k):
suma = 0
arr1 = []
for i in range(0, len(arr)):
arr1.append(arr[i] + k * (i + 1))
arr1.sort()
if k == 1:
return arr1[0] + 1
for i in range(0, k):
try:
suma = suma + arr1[i]
except:
adfasdf = 0
return suma
n, S = map(int... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER RETURN BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER RETURN VAR ASSIGN VAR... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def check(arr, k):
arr1 = arr[:]
for i in range(n):
arr1[i] = arr1[i] + (i + 1) * k
arr1 = sorted(arr1)
return sum(arr1[:k])
n, s = map(int, input().split())
arr = list(map(int, input().split()))
l = 1
r = n
ans1, ans2 = 0, int(2000000000.0)
while l <= r:
mid = (l + r) // 2
cost = chec... | FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR 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 ... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | def can_buy(num, n, budget, base_costs):
costs = [(base_costs[i] + (i + 1) * num) for i in range(n)]
costs.sort()
temp = sum(costs[:num])
if temp <= budget:
return True, temp
else:
return False, 0
def solve(n, budget, base_costs):
start = 0
end = n
k = 0
cost = 0
... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR RETURN NUMBER VAR RETURN NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR ... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | n, s = map(int, input().split())
a = list(map(int, input().split()))
l, r, res = 0, n, 0
while l <= r:
m = (l + r) // 2
f = sorted([(a[i] + (i + 1) * m) for i in range(n)])
g = sum(f[:m])
if g <= s:
l, res = m + 1, g
else:
r = m - 1
print(l - 1, res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUN... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | from itertools import count
n, m = list(map(int, input().split()))
p = [int(num) for num in input().split()]
def calc(cnt):
new_p = list(map(lambda ind, num: num + cnt * ind, count(1), p))
return sum(sorted(new_p)[:cnt])
def can(cnt):
return calc(cnt) <= m
l = 0
r = n + 1
while r - l > 1:
mid = (... | 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 FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR FUNC_CALL VAR NUMBER VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR N... |
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x_2, ..., x_{k}, then t... | for _ in range(1):
n, budget = map(int, input().split())
costs = list(map(int, input().split()))
start = 0
end = n + 1
while start < end - 1:
mid = start + (end - start) // 2
binary = [(0) for _ in range(n)]
for i in range(n):
binary[i] = costs[i] + (i + 1) * mid
... | FOR VAR FUNC_CALL VAR NUMBER 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 VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR F... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | cnt1, cnt2, x, y = map(int, input().split())
upper_limit = (cnt1 + cnt2) * (x * y) // (x * y - x - y + 1)
def bin_search(low, high):
if low >= high - 1:
return high
mid = (low + high) // 2
best_way = max(0, cnt1 - mid // y + mid // (x * y)) + max(
0, cnt2 - mid // x + mid // (x * y)
)
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER FUNC_DEF IF VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR BIN_OP ... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | def spliter():
d = input()
a = d.split()
r = []
for i in a:
k = int(i)
r.append(k)
return r
def counter(a, b):
i = a // b
j = i
while i > 0:
a += i
i = a // b - j
j += i
return a
lst = spliter()
l1 = lst[0]
l2 = lst[1]
l3 = lst[2]
l4 = lst[... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | cnt1, cnt2, x, y = list(map(int, input().split()))
def present(v, x, y, cnt1, cnt2):
div_x = v // x
div_y = v // y
div_xy = v // (x * y)
div_x -= div_xy
div_y -= div_xy
left = v - (div_x + div_y + div_xy)
cnt1 -= div_y
cnt2 -= div_x
cnt1 = cnt1 if cnt1 > 0 else 0
cnt2 = cnt2 if... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMB... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | cnt1, cnt2, x, y = list(map(int, input().split(" ")))
lo = 1
hi = 10**10
while lo < hi:
xx = cnt1
yy = cnt2
mid = (lo + hi) // 2
intx = mid // x
inty = mid // y
intxy = mid // (x * y)
notxy = mid - intx - inty + intxy
notx = mid - intx - notxy
noty = mid - inty - notxy
xx -= notx... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR ... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | a, b, c, d = map(int, input().split())
l = 1
r = 10**10
while r - l > 1:
m = (r + l) // 2
both = m // (c * d)
f = [m // c, m // d]
other = m - f[0] - f[1] + both
f[0] -= both
f[1] -= both
if max(0, b - f[0]) + max(0, a - f[1]) <= other:
r = m
else:
l = m
print(r) | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR NUM... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | cnt_1, cnt_2, x, y = map(int, input().split())
l = 0
r = 10**18
lcm = x * y
while r > l + 1:
mid = (l + r) // 2
if mid - mid // x < cnt_1 or min(mid - cnt_1 - mid // lcm, mid - mid // y) < cnt_2:
l = mid
else:
r = mid
print(r) | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR V... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | def check(v):
a = v // y - v // (x * y)
b = v // x - v // (x * y)
c = v - (a + b + v // (x * y))
fa = c + a
fb = min(c, fa - cnt1) + b
return fa >= cnt1 and fb >= cnt2
cnt1, cnt2, x, y = list(map(int, input().split()))
l, r = 0, (cnt1 + cnt2) * 2
while l <= r:
mid = (l + r) // 2
if che... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR VAR RETURN VAR VAR VAR VAR ASSIGN VAR VAR VAR ... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | c1, c2, x, y = map(int, input().split())
l, r = 0, 1 << 179
while r - l > 1:
m = l + r >> 1
if m - m // x >= c1 and m - m // y - max(0, c1 - m // y + m // x // y) >= c2:
r = m
else:
l = m
print(r) | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VA... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | cnt1, cnt2, x, y = map(int, input().split())
do = cnt1 + cnt2
up = 10**12
def checker(mid):
if (
mid - mid // x >= cnt1
and mid - mid // y - max(cnt1 - mid // y + mid // (y * x), 0) >= cnt2
):
return True
elif (
mid - mid // y >= cnt2
and mid - mid // x - max(cnt2 -... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IF BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR NUMBER VAR RETURN NUMBER IF BIN_OP VAR BIN_OP VAR... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | R = lambda: map(int, input().split())
c1, c2, x, y = R()
l, r = c1 + c2, 2 * 10**9 + 7
while l < r:
m = (l + r) // 2
r1 = max(0, c1 - m // y + m // (x * y))
r2 = max(0, c2 - m // x + m // (x * y))
if m - m // x - m // y + m // (x * y) < r1 + r2:
l = m + 1
else:
r = m
print(l) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | def valid(n1, n2, p1, p2, mid):
x = mid - mid // p1
y = mid - mid // p2
rem = mid - mid // (p1 * p2)
return x < n1 or y < n2 or rem < n1 + n2
def binary_search(n1, n2, p1, p2):
l, r = 0, 1 << 61
while l <= r:
mid = l + r >> 1
if valid(n1, n2, p1, p2, mid):
l = mid +... | FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR RETURN VAR VAR VAR VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR ASSI... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | from sys import stdin
lines = list([_f for _f in stdin.read().split("\n") if _f])
def parseline(line):
return list(map(int, line.split()))
lines = list(map(parseline, lines))
def search(f, v, l, r):
while l + 1 < r:
p = l + (r - l) // 2
if f(p) <= v:
l = p
else:
... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | def Solve(n, m, sum):
cnt = int(sum / x / y)
if x == y:
cnt = int(sum / x)
n = max(0, n - int(sum / y) + cnt)
m = max(0, m - int(sum / x) + cnt)
if sum - int(sum / x) - int(sum / y) + cnt >= n + m:
tmp = 0
else:
tmp = m + n - (sum - int(sum / x) - int(sum / y) + cnt)
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR B... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | line = input().split()
cnt1 = int(line[0])
cnt2 = int(line[1])
x = int(line[2])
y = int(line[3])
maxNum = 100000000000
def solve(n):
a = n // x
b = n // y
both = n // (x * y)
only_a = a - both
only_b = b - both
curr_cnt1 = max(0, cnt1 - only_b)
curr_cnt2 = max(0, cnt2 - only_a)
shared ... | 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 VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | c1, c2, x, y = map(int, input().split())
l = c1 + c2
temp = l
h = pow(10, 10)
while l < h:
ans = (l + h) // 2
if c1 > ans - ans // x or c2 > ans - ans // y or temp > ans - ans // (x * y):
l = ans + 1
else:
h = ans
print(l) | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | def works(v):
shared = v // (x * y)
cnt_1loc, cnt_2loc = v // x, v // y
split = v - cnt_1loc - cnt_2loc + shared
cnt_1loc, cnt_2loc = cnt_1loc - shared, cnt_2loc - shared
return max(cnt1 - cnt_2loc, 0) + max(cnt2 - cnt_1loc, 0) <= split
cnt1, cnt2, x, y = map(int, input().split())
low, mid, high =... | FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | cnt1, cnt2, x, y = map(int, input().split())
l = 0
r = (cnt1 // (x - 1) + 1) * x + (cnt2 // (y - 1) + 1) * y + 5
while r - l != 1:
m = l + (r - l) // 2
t_cnt1 = m // y - m // (x * y)
t_cnt2 = m // x - m // (x * y)
if max(0, cnt1 - t_cnt1) + max(0, cnt2 - t_cnt2) <= m - (
m // x + m // y - m // (... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP ... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | c1, c2, x, y = map(int, input().split())
xy = x * y
n = 1
while n - n // x < c1 or n - n // y < c2 or n - n // xy < c1 + c2:
n = n << 1
l = 1
r = n
while r - l > 1:
m = r + l >> 1
if m - m // x < c1 or m - m // y < c2 or m - m // xy < c1 + c2:
l = m
else:
r = m
m = l
if m - m // x < c1 o... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | c1, c2, x, y = map(int, input().split())
def fn(val):
f = [val // x, val // y]
both = val // (x * y)
f = [(i - both) for i in f]
oth = val - f[0] - f[1] - both
cnt = [c1 - f[1], c2 - f[0]]
if cnt[0] < 0:
cnt[0] = 0
if cnt[1] < 0:
cnt[1] = 0
return sum(cnt) <= oth
l = ... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR ASSIGN VAR LIST BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER IF VAR ... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | cnt1, cnt2, x, y = [int(x) for x in input().split()]
lo, hi = 1, 10 * (cnt1 + cnt2)
while lo < hi:
mid = (lo + hi) // 2
div_by_both = mid // (x * y)
div_by_x_only = mid // x - div_by_both
div_by_y_only = mid // y - div_by_both
total_wasted = div_by_both
total_wasted += div_by_y_only - min(cnt1, ... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP NUMBER BIN_OP VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR FUNC_... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | c1, c2, x, y = map(int, input().split())
def valid(m):
a = m - m // x
b = m - m // y - max(0, c1 - m // y + m // x // y)
return a >= c1 and b >= c2
l, r = 0, 1 << 62
while l + 1 < r:
m = l + r >> 1
if valid(m):
r = m
else:
l = m
print(r) | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR VAR VAR VAR ASSIGN VAR VAR NUMBER BIN_OP NUMBER NUMBER WHILE BIN_OP VAR NU... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | a, b, x, y = map(int, input().split())
l, r = a + b, (a + b) * 5
while l < r:
v = (l + r) // 2
if v - v // x >= a and v - v // y >= b and v - v // (x * y) >= a + b:
r = v
else:
l = v + 1
print(r) | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR B... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | c1, c2, x, y = list(map(int, input().split()))
def get(n):
if n - n // (x * y) >= c1 + c2 and n - n // x >= c1 and n - n // y >= c2:
return True
else:
return False
l = 0
r = c1 * x + c2 * y
while r - l > 1:
m = (l + r) // 2
if get(m):
r = m
else:
l = m
print(r) | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR NU... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | c1, c2, x, y = map(int, input().split())
def poss(v):
global c1, c2, x, y
divbyx = v // x
divbyy = v // y
divbyxy = v // (x * y)
cc1 = c2 - divbyx + divbyxy
cc2 = c1 - divbyy + divbyxy
cc1 = max(cc1, 0)
cc2 = max(cc2, 0)
remaining = v - divbyx - divbyy + divbyxy
if cc1 + cc2 <=... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR ... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | n, m, x, y = map(int, input().split())
tmp = [1]
def judge(n, m, sum, tmp):
cnt = int(sum / x / y)
if x == y:
cnt = int(sum / x)
n = max(0, n - int(sum / y) + cnt)
m = max(0, m - int(sum / x) + cnt)
if sum - int(sum / x) - int(sum / y) + cnt >= n + m:
tmp = sum
re = 0
e... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | a, b, x, y = map(int, input().split())
l = 0
r = 10000000000000
res = 0
def judge(n, a, b, x, y):
return n - n // (x * y) >= a + b and n - n // x >= a and n - n // y >= b
while l <= r:
m = (l + r) // 2
if judge(m, a, b, x, y):
r = m - 1
res = m
else:
l = m + 1
print(res) | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VA... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | def gcd(a, b):
return b if a % b == 0 else gcd(b, a % b)
cntx, cnty, x, y = list(map(int, input().split()))
d = x * y // gcd(x, y)
v = cnt = 0
while cntx + cnty > cnt:
dxy = cntx + cnty - cnt
cx = (v + dxy) // x - v // x
cy = (v + dxy) // y - v // y
cxy = (v + dxy) // d - v // d
cnt += dxy - c... | FUNC_DEF RETURN BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER WHILE BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BI... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | class FriendsPresents:
def __init__(self, c1, c2, x, y):
self.c1, self.c2, self.x, self.y = c1, c2, x, y
def check(self, v):
xval = int(v / self.x)
yval = int(v / self.y)
xyval = int(v / (self.x * self.y))
c1rem = max(0, self.c1 - (yval - xyval))
c2rem = max(0, ... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR VAR IF BIN... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | def main():
cnt1, cnt2, x, y = map(int, input().split())
lo = cnt3 = cnt1 + cnt2
hi, z = 10**10, x * y
while lo < hi:
v = (lo + hi) // 2
if v - v // x < cnt1 or v - v // y < cnt2 or v - v // z < cnt3:
lo = v + 1
else:
hi = v
print(lo)
main() | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP NUMBER NUMBER BIN_OP VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP ... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | import sys
__author__ = "neki"
words = input().split()
cnt1 = int(words[0])
cnt2 = int(words[1])
x = int(words[2])
y = int(words[3])
def determine(num, x, y, cnt1, cnt2):
like1 = num - num // x
like2 = num - num // y
like1and2 = like1 + like2 - num + num // (x * y)
friend1 = like1 - like1and2
fri... | IMPORT ASSIGN VAR STRING 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 VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP V... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | s = input()
c1, c2, x, y = list(map(int, s.split()))
l = 0
r = int(1e18)
while r - l > 1:
m = (l + r) // 2
d1 = m // x
d2 = m // y
b = m // (x * y)
k1 = d2 - b
k2 = d1 - b
rr = m - d1 - d2 + b
r1 = max(0, c1 - k1)
r2 = max(0, c2 - k2)
if rr >= r1 + r2:
r = m
else:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP V... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | s = input()
arrIn = s.split()
n = int(arrIn[0])
m = int(arrIn[1])
x = int(arrIn[2])
y = int(arrIn[3])
l = 1
r = 2000000000.0
while l < r:
mid = int((r + l) / 2)
if (
n <= mid - int(mid / x)
and m <= mid - int(mid / y)
and m + n <= mid - int(mid / (x * y))
):
r = mid
else:... | 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 VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP VAR FUNC... |
You have two friends. You want to present each of them several positive integers. You want to present cnt_1 numbers to the first friend and cnt_2 numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the f... | n0, n1, x, y = map(int, input().split())
def f(m, n, x, y):
return max(0, n - (m // y - m // (x * y)))
lo = -1
hi = x * y * (n0 + n1)
while lo + 1 < hi:
mid = lo + (hi - lo) // 2
if f(mid, n0, x, y) + f(mid, n1, y, x) <= mid - mid // x - mid // y + mid // (
x * y
):
hi = mid
else... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP FUNC... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, k, m = map(int, input().split())
l = [int(i) for i in input().split()]
def ispzbl(l, n, m, k, mid):
z = l[mid:]
if not z:
return True
s = 0
box = 1
for i in z:
s += i
if s > m:
box += 1
s = i
return box <= k
low = 0
high = n - 1
while low <=... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR IF VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBE... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = [int(x) for x in input().split()]
ns = [int(x) for x in input().split()]
ns.reverse()
rem = k
num = 0
ans = []
for i in range(n):
if rem >= ns[i]:
rem -= ns[i]
num += 1
else:
ans.append(num)
rem = k - ns[i]
num = 1
if num > 0:
ans.append(num)
if len(ans) <= ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR NU... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | s = [int(i) for i in input().split()]
n, m, k = s[0], s[1], s[2]
arr = [int(i) for i in input().split()]
present = 0
box = 1
index = -1
for o in range(n - 1, -1, -1):
if present + arr[o] > k:
present = arr[o]
box += 1
else:
present += arr[o]
if box > m:
index = o
brea... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER 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 BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR V... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = list(map(int, input().split()))
cnt = 0
count = 0
sum = 0
a = [int(s) for s in input().split()]
for i in range(n - 1, -1, -1):
sum += a[i]
if sum > k:
sum = a[i]
count += 1
if count >= m:
break
cnt += 1
print(cnt) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER EXPR ... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | def check(a, m, mx):
t = mx
for i in a:
if t - i >= 0:
t -= i
elif m - 1 > 0:
m -= 1
t = mx - i
else:
return False
return True
def f(m, mx, a):
hi = len(a)
lo = 0
res = 0
while lo <= hi:
mid = (lo + hi) // 2
... | FUNC_DEF ASSIGN VAR VAR FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR V... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | ar = []
read = input().split(" ")
n = int(read[0])
m = int(read[1])
k = int(read[2])
read = input().split(" ")
for i in range(n):
ar.append(int(read[i]))
cap = k
i = n - 1
while m > 0 and i >= 0:
if cap - ar[i] >= 0:
cap -= ar[i]
i -= 1
elif m > 0:
m -= 1
cap = k
else:
... | ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER W... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | w, m, k = map(int, input().split())
a = list(map(int, input().split()))
i = w
s = k
while i > 0 and m > 0:
i -= 1
if s < a[i]:
m -= 1
s = k
s -= a[i]
if m == 0:
print(w - i - 1)
else:
print(w - i) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUN... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, M, K = map(int, input().split())
l = list(map(int, input().split()))
num = 0
k = K
m = M
for j in range(n - 1, -1, -1):
if m <= 0:
break
elif k >= l[j]:
k -= l[j]
num += 1
else:
m -= 1
if m <= 0:
break
else:
k = K
k -= l[... | ASSIGN VAR 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 ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VA... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = list(map(int, input().split()))
arr = list(map(int, input().split()))
low, high = 0, n - 1
while low < high:
mid = (low + high) // 2
ans = [k for i in range(m)]
flag = 0
ind = 0
for j in range(mid, n):
cur = arr[j]
prev = ind
while True:
if ans[ind] < cu... | ASSIGN VAR 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 VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUN... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = map(int, input().split())
a = list(map(int, input().split()))
n = n - 1
count = 0
while m > 0 and n >= 0:
ktemp = k
while ktemp >= a[n] and n >= 0:
ktemp = ktemp - a[n]
n = n - 1
count = count + 1
m = m - 1
print(count) | ASSIGN VAR 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 VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | def check(num):
left = m
curr = k
for i in range(n - num, n):
if curr >= a[i]:
curr -= a[i]
else:
if left == 1:
return False
left -= 1
curr = k - a[i]
return True
n, m, k = map(int, input().split())
a = list(map(int, input... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR IF VAR NUMBER RETURN NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR RETURN NUMBER ASSIGN VAR 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 AS... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | obj, n_caixas, size = input().split()
n_caixas, size = int(n_caixas), int(size)
objts = [int(x) for x in input().split()]
objts.reverse()
current_box_size = size
count_obj = 0
for o in objts:
if n_caixas < 1:
break
if o <= current_box_size:
current_box_size -= o
count_obj += 1
co... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR VA... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a = a[::-1]
boxes = 0
ans = 0
loc = 0
for i in range(n):
loc += a[i]
if loc > k:
boxes += 1
loc = a[i]
if boxes == m:
break
ans += 1
print(ans) | ASSIGN VAR 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 NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VA... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = map(int, input().split())
a = [int(i) for i in input().split()]
def cond(x):
box_cnt = m
capacity = k
for i in range(n - x - 1, n):
if capacity >= a[i]:
capacity -= a[i]
else:
box_cnt -= 1
capacity = k - a[i]
return box_cnt <= 0
lo, hi = ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR RETURN VAR NUMBER ASSIGN VAR VAR NUMBER ... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | import sys
input = sys.stdin.readline
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
a = a[::-1]
cnt_box = 1
ca = 0
s = 0
for i in range(n):
if s + a[i] <= k:
s += a[i]
ca += 1
else:
s = 0
cnt_box += 1
if cnt_box <= m:
s += a[i]
... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER V... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | import sys
def minp():
return sys.stdin.readline().strip()
n, mm, k = map(int, minp().split())
a = list(map(int, minp().split()))
def tt(x):
m = mm - 1
c = 0
for j in range(x, n):
i = a[j]
if c + i > k:
if m == 0 or i > k:
return False
c = i
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR VAR VAR IF VAR NUMBER VAR ... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | def get_input_list():
return list(map(int, input().split()))
n, m, k = get_input_list()
a = get_input_list()
b = 0
c = k
i = n - 1
r = 0
while True:
if c < a[i]:
b += 1
if b == m:
break
c = k
c -= a[i]
r += 1
i -= 1
if i < 0:
break
print(r) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMB... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | import sys
input = sys.stdin.readline
def main():
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
if min(a) > k:
return 0
a = a[::-1]
current = 0
answer = 0
for i in range(n):
if current + a[i] <= k:
current += a[i]
answer +=... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR 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 RETURN NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR ... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = map(int, input().split())
A = list(map(int, input().split()))
def is_ok(x):
cnt = 1
cur = 0
for i in range(n - x, n):
if cur + A[i] <= k:
cur += A[i]
else:
cnt += 1
cur = A[i]
if cnt <= m:
return True
else:
return False
... | ASSIGN VAR 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = map(int, input().split())
u = list(map(int, input().split()))
def chek(M):
p = k
t = m
for i in range(M, n):
if p - u[i] >= 0:
p -= u[i]
elif t > 1:
t -= 1
p = k - u[i]
if p < 0:
return False
else:
... | ASSIGN VAR 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 VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR VAR NUMBER VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER RETURN NUMBER... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = map(int, input().split())
a = list(map(int, input().split()))
a = list(reversed(a))
cnt = 0
K = k
ans = 0
for i in range(n):
if a[i] <= K:
K -= a[i]
else:
cnt += 1
K = k - a[i]
if cnt == m:
break
ans += 1
print(ans) | ASSIGN VAR 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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF V... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | kk = input().split()
n = int(kk[0])
m = int(kk[1])
k = int(kk[2])
objs = list(map(int, input().split()))
if m >= n:
print(n)
else:
objs = objs[::-1]
sum_ = 0
items = 0
l = list()
for obj in objs:
if sum_ + obj <= k:
sum_ += obj
items += 1
else:
... | 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 VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CA... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | import sys
mod = 10**9 + 7
INF = float("inf")
def inp():
return int(sys.stdin.readline())
def inpl():
return list(map(int, sys.stdin.readline().split()))
n, m, k = inpl()
a = inpl()
a = a[::-1]
now = k
for i, x in enumerate(a):
if x > k:
break
if now >= x:
now -= x
else:
... | IMPORT ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FOR VAR VAR FUNC_CALL VA... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = list(map(int, input().split()))
list_a = list(map(int, input().split()))
list_a.reverse()
count_b = 0
sum_now = 0
ans = 0
i = 0
while i < n:
if count_b >= m:
ans = i - 1
break
sum_now += list_a[i]
if sum_now > k:
sum_now = 0
count_b += 1
else:
i += 1
els... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | def main():
nobj, nbox, boxsize = list(map(int, input().split()))
obj = list(map(int, input().split()))
box = boxsize
curr = 0
ans = 0
i = nobj - 1
while i >= 0:
o = obj[i]
if o <= box:
box -= o
ans += 1
else:
curr += 1
... | FUNC_DEF ASSIGN VAR 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 VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR V... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | import sys
input = sys.stdin.readline
def judge(x):
cnt = 1
remain = k
for i in range(n - x, n):
if remain - a[i] >= 0:
remain -= a[i]
else:
if a[i] > k:
return False
cnt += 1
remain = k - a[i]
return cnt <= m
def binar... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR NUMBER VAR VAR VAR IF VAR VAR VAR RETURN NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | from sys import stdin, stdout
en, m, k = [int(x) for x in stdin.readline().split()]
a = [int(x) for x in stdin.readline().split()]
n = []
c = k
boxes = 1
for x in a:
if c >= x:
c -= x
else:
boxes += 1
c = k - x
n.append(boxes)
totalB = n[-1]
if totalB <= m:
print(en)
else:
l... | ASSIGN VAR 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 ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR AS... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | def fit(a, m, k, res):
k1 = k
for ai in a[-res:]:
if ai <= k1:
k1 -= ai
else:
k1 = k - ai
if m == 1:
return False
else:
m -= 1
return True
def bisect(n, m, k, a):
left, right = 0, n + 1
while left + 1 <... | FUNC_DEF ASSIGN VAR VAR FOR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER VAR NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RE... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = map(int, input().split())
a = list(map(int, input().split()))
count = 0
curr = 0
i = n
while count < m and i >= 0:
i -= 1
if curr + a[i] <= k:
curr += a[i]
else:
count += 1
curr = a[i]
print(n - i - 1) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR ... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, k, m = map(int, input().split())
l = list(map(int, input().split()))
tot = 0
ans = 1
s = 0
for i in range(n - 1, -1, -1):
s += l[i]
if s > m:
s = l[i]
ans += 1
if ans > k:
break
tot += 1
print(tot) | ASSIGN VAR 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 VAR NUMBER NUMBER NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | import sys
def minp():
return sys.stdin.readline().strip()
n, mm, k = list(map(int, minp().split()))
a = list(map(int, minp().split()))
def tt(x):
m = mm - 1
c = 0
res = 0
for i in reversed(a):
if c + i > k:
if m == 0 or i > k:
return res
c = i
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR IF VAR NU... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = k
count = 0
for obj in a[::-1]:
if obj > k:
break
if obj > b:
if m > 1:
m -= 1
b = k - obj
count += 1
else:
break
else:
b -= obj
count... | ASSIGN VAR 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 ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR VAR IF VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | import sys
def test(pos):
current_pack = k
count = 1
for i in range(pos, n):
if a[i] > current_pack:
count += 1
current_pack = k - a[i]
else:
current_pack -= a[i]
if count > m:
return False
else:
return True
def bs(l, r):
l1... | IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR NU... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = map(int, input().split())
t = list(map(int, input().split()))
tmp_sum = 0
wyn = 0
z = 0
for x in range(len(t) - 1, -1, -1):
if m == 0:
break
tmp_sum += t[x]
if x != 0:
wyn += 1
if tmp_sum + t[x - 1] > k:
m -= 1
tmp_sum = 0
elif tmp_sum <= k:
... | ASSIGN VAR 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 NUMBER NUMBER IF VAR NUMBER VAR VAR VAR IF VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR B... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = map(int, input().split())
a = input().split()
a = [int(x) for x in a]
a.reverse()
box = 0
fruits = 0
m -= 1
for i, x in enumerate(a):
if box + x <= k:
box += x
continue
m -= 1
if m < 0:
fruits = i
break
box = x
else:
print(n)
exit()
print(i) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR EXPR F... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | def main():
n, m, k = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
box = 0
b_id = 0
count = 0
for i in range(len(a) - 1, -1, -1):
if box + a[i] <= k:
box += a[i]
count += 1
else:
if b_id + 1 >= m:
brea... | FUNC_DEF ASSIGN VAR 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 BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMB... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | input1 = input().split()
num_objects = int(input1[0])
num_boxes = int(input1[1])
box_size = int(input1[2])
objects = [int(x) for x in input().split()]
max_objects_packed = 0
current_box_size = box_size
remaining_boxes = num_boxes
objects_packed = 0
i = num_objects - 1
while i >= 0 and remaining_boxes != 0:
if objec... | 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 VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR NUMB... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, b, k = map(int, input().split())
a = [int(i) for i in input().split()]
j, m, s, ans = 0, 1, 0, 0
for i in range(len(a) - 1, -1, -1):
if m <= b and s + a[i] <= k:
ans += 1
s += a[i]
elif m + 1 <= b and a[i] <= k:
ans += 1
s = a[i]
m += 1
else:
break
print(an... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR BIN_OP VAR VAR VAR VAR VAR NUMBER VAR VAR VAR IF BIN_OP VAR NUMBER VAR V... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
i = n - 1
tec = k
res = 0
while i >= 0 and m > 0:
if a[i] <= tec:
tec -= a[i]
res += 1
i -= 1
else:
m -= 1
tec = k
print(res) | ASSIGN VAR 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 VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = map(int, input().split())
arr = list(reversed(list(map(int, input().split()))))
has = cnt = 0
for v in arr:
if v + has <= k:
has += v
elif v > k:
print(0)
exit(0)
else:
has = v
m -= 1
if m == 0:
break
else:
cnt += 1
print(cnt) | ASSIGN VAR 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 VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR NUMB... |
Maksim has $n$ objects and $m$ boxes, each box has size exactly $k$. Objects are numbered from $1$ to $n$ in order from left to right, the size of the $i$-th object is $a_i$.
Maksim wants to pack his objects into the boxes and he will pack objects by the following algorithm: he takes one of the empty boxes he has, goe... | n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
summ = []
cur = 0
for item in a[::-1]:
cur += item
summ.append(cur)
def helper(x, summ, l, r):
while l < r:
mid = l + (r - l + 1) // 2
if summ[mid] > x:
r = mid - 1
else:
l = mid
... | ASSIGN VAR 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 LIST ASSIGN VAR NUMBER FOR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.