description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = sorted(map(int, input().split()))
c = 1
i = n // 2
s = a[i]
while i < n - 1 and k > 0:
t = min(a[i + 1] - s, k // c)
s += t
k -= t * c
c += 1
i += 1
if k > 0:
s += k // c
print(s) | 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 ASSIGN VAR VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
med = l[n // 2]
for i in range(n // 2 + 1, n):
diff = l[i] - l[i - 1]
if diff > 0:
if k >= diff * (i - n // 2):
med = l[i]
k -= diff * (i - n // 2)
else:
if k >= i - n // 2... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR BIN_OP VAR BIN_OP VAR B... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | a, b = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
index = a // 2 + 1
count = 1
while b > 0:
if index == a:
l[a // 2] += b // (a // 2 + 1)
break
diff = l[index] - l[a // 2]
if count * diff <= b:
b -= count * diff
count += 1
index += 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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
mid = (n - 1) // 2
while k > 0:
i = mid
while i < n and a[i] == a[mid]:
i += 1
res = i - mid
if res == 0:
k -= a[mid + 1]
if k >= 0:
a[mid] = a[mid + 1]
else:
a[mid] +=... | 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 ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER IF VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
if n == 1:
print(a[0] + k)
else:
a.sort()
x = n // 2
if a[x] + k <= a[x + 1]:
print(a[x] + k)
else:
nextelem = x + 1
countelem = 1
incer = 0
prev = a[x]
while nextelem < n:
... | 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 IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mid = int(n / 2)
up = mid + 1
while k > 0:
if up >= n:
k -= n - mid
a[mid] += 1
elif a[up] == a[mid]:
up += 1
else:
k -= up - mid
a[mid] += 1
if k == 0:
print(a[mid])
else:
print(a[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 ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | import sys
input = sys.stdin.readline
def judge(x):
cnt = 0
for i in range(n // 2, n):
cnt += max(x - a[i], 0)
return cnt <= k
def binary_search():
left, right = 1, 10**20
while left <= right:
mid = (left + right) // 2
if judge(mid):
left = mid + 1
el... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER RETURN 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 ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR B... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(sorted(map(int, input().split())))
count = a[n // 2]
num = 1
for i in range(n // 2 + 1, n):
if (a[i] - count) * num <= k:
k -= (a[i] - count) * num
count = a[i]
else:
break
num += 1
print(count + k // num) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR AS... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
arr = list(map(int, input().split()))
if n == 1:
print(arr[0] + k)
exit(0)
arr.sort()
i = (n - 1) // 2
m = arr[i]
cnt = 1
i += 1
while i < n:
nxt = arr[i]
if k < (nxt - m) * cnt:
print(m + k // cnt)
exit(0)
k -= (nxt - m) * cnt
m = nxt
cnt += ... | 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 VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER VAR NUMBER WHILE... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
med = len(a) // 2
look = med
extra = 0
idiff = 0
last = a[med]
while look < len(a) - 1:
look += 1
idiff += 1
diff = a[look] - last
last = a[look]
chunk = idiff * diff
if chunk <= k:
k -= chunk
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def int_multiple():
return [int(c) for c in input().split()]
def int_single():
return int(input())
def str_multiple():
return [c for c in input().split()]
def str_single():
return input()
n, k = int_multiple()
l = int_multiple()
l = sorted(l)
mid = int(n / 2)
l = l[mid:]
acc = []
r = 0
for i in ... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def median(l, n, k):
l = l[n // 2 :]
n = n // 2 + 1
diffs = []
for i in range(n - 1):
diffs.append((l[i + 1] - l[i]) * (i + 1))
diff = sum(diffs)
if diff <= k:
k -= diff
last = l[-1] + k // n
k %= n
return last
else:
t = 0
val = l[0]
... | FUNC_DEF ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | attributes = [int(x) for x in input().split()]
ints = [int(x) for x in input().split()]
ints.sort()
length = len(ints)
n = len(ints) // 2 - 1
r = n
cont = True
while cont == True:
r += 1
t = ints[r]
z = r + 1
while z < length and ints[z] == ints[r]:
z += 1
if z != length:
if (ints[z]... | 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
ind, val = n // 2, 0
ans, ind1 = a[ind], 1
for i in range(ind + 1, n):
val = (a[i] - a[i - 1]) * ind1
if k - val >= 0:
k -= val
ind1 += 1
ans = a[i]
else:
ans = a[i - 1] + k // ind1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR IF BIN_OP ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
a = a[len(a) // 2 :]
m = 1
while m < len(a) and k - (a[m] - a[0]) * m >= 0:
k -= (a[m] - a[0]) * m
a[0] = a[m]
m += 1
a[0] += k // m
print(a[0]) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR NUMB... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | a, b = map(int, input().split())
z = sorted(map(int, input().split()))
def ok(mid):
clk = 0
for i in range(a // 2, a):
clk += max(0, mid - z[i])
if clk > b:
return False
return True
def bin_s():
lo, hi, ans = 1, 2 * int(1000000000.0), 0
while lo <= hi:
mid = (... | 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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR VAR NUMBER BIN_OP ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
p = [0] * (n // 2)
m = n // 2
ans = a[m]
s = 0
for i in range(m + 1, n):
p[i - m - 1] = a[i] - a[i - 1]
s += p[i - m - 1] * (i - m)
if k < s:
for i in range(m):
r = p[i] * (i + 1)
if k >= r:
k -= r
... | 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 BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP B... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def mp():
return map(int, input().split())
n, k = mp()
a = list(mp())
a.sort()
l = 1
r = 10**20
while l + 1 < r:
m = (l + r) // 2
s = 0
for i in range(n // 2, n):
s += max(0, m - a[i])
if k < s:
r = m
else:
l = m
print(l) | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def check(x):
suma = 0
for i in range(n // 2, n):
suma += x - a[i]
if suma > k:
return False
if suma <= k:
return True
return False
n, k = [int(x) for x in input().split()]
a = list(map(int, input().split()))
a.sort()
l = 1
r = 2000000000
while l != r:
mid = (l ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER 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 VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMB... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
A = sorted([int(x) for x in input().split()])
A += [2 * 10**9 + 1]
mid = n // 2
i = mid
result = -1
while k > 0:
while A[i] == A[i + 1]:
i += 1
d = A[i + 1] - A[i]
if (i + 1 - mid) * d <= k:
k -= (i + 1 - mid) * d
i += 1
result = A[i]
else... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | a, b = map(int, input().split())
c = list(map(int, input().split()))
c.sort()
m = c[a // 2]
n = c[a // 2] + b
def check(mid):
s = 0
for i in range(a // 2, a):
if mid > c[i]:
s += mid - c[i]
else:
break
return s
while m <= n:
mid = (m + n) // 2
if check(mid... | 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 VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR BIN_OP VAR... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
x = len(a) // 2
rem = 1
ans = a[x]
while k > 0:
if x + rem < len(a):
if k >= rem * (a[x + rem] - a[x + rem - 1]):
k -= rem * (a[x + rem] - a[x + rem - 1])
ans = a[x + rem]
rem += 1
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR NUMBER IF BIN_OP VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR BIN_OP VAR B... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | import sys
n, k = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]
if n == 1:
print(k + data[0])
sys.exit()
data.sort()
data = data[n // 2 :]
n = n // 2 + 1
sumto = [data[0]]
for i in range(1, n):
sumto.append(sumto[-1] + data[i])
ans = n - 1
for i in range(1, n):
am = i * dat... | IMPORT 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 EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST VAR NUMBER... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
s = sorted(map(int, input().split()))
j = n // 2
i = n // 2
m = s[i]
def meadian(i, j, m, s, k):
while i < n - 1:
t = (s[i + 1] - m) * (i + 1 - j)
if t <= k:
k -= t
m = s[i + 1]
else:
break
i += 1
return m + 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 BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_DEF WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR IF... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
S = list(map(int, input().split()))
S.sort()
S = S[n // 2 :]
ind = 0
while True:
if ind == n // 2 or k < ind + 1:
print(S[ind] + k // (n // 2 + 1))
break
else:
if S[ind] == S[ind + 1]:
ind += 1
continue
if (S[ind + 1] - S[i... | 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 VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR NUM... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def solve(a, n, k):
if n == 1:
return a[0] + k
a.sort()
total = sum(a[n // 2 :]) + k
avg = total // (n // 2 + 1)
remain = total % (n // 2 + 1)
element = n // 2 + 1
for i in range(n - 1, n // 2 - 1, -1):
if a[i] <= avg + remain and a[i - 1] <= avg:
return avg
... | FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def solve():
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)
median = int(n / 2)
left = a[median]
right = 2 * 1000 * 1000 * 1000
while left < right:
middle = int((left + right + 1) / 2)
need = 0
for i in range(median, n, 1):
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))[n // 2 :]
f = 1
i = 1
while k != 0 and i < len(a):
r = a[i] - a[0]
if r == 0:
f += 1
i += 1
continue
if f * r <= k:
a[0] += r
k -= r * f
else:
a[0] += k // f
k = 0
f +... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
b = list(map(int, input().split()))
b.sort()
m = b[(n - 1) // 2]
j = (n - 1) // 2
p = 1
while j < n - 1:
if k >= p * (b[j + 1] - b[j]):
m = b[j + 1]
k += -p * (b[j + 1] - b[j])
p += 1
j += 1
else:
break
print(m + k // p) | 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 VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR N... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = [int(i) for i in input().split()]
ns = [int(i) for i in input().split()]
ns2 = ns
ns2.sort()
meio = n // 2
ns2 = ns2[meio:]
arrdif = []
arrdif.append(ns2[0])
for i, item in enumerate(ns2[1:]):
arrdif.append(item - ns[i + meio])
for i, dif in enumerate(arrdif[1:]):
if dif > 0:
aux = dif * (i + 1)
... | 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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = sorted(map(int, input().split()))
if n == 1:
print(k + a[0])
raise SystemExit
d = [a[0]] + [(a[i + 1] - a[i]) for i in range(len(a) - 1)]
for i in range(n // 2 + 1, n):
if k <= 0:
break
e = min(k // (i - n // 2), d[i])
d[n // 2] += e
d[i] -= e
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 IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP LIST VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CAL... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def max_median(n, m, lst):
j, r = n // 2, n // 2 + 1
while m and r < n:
if lst[j] == lst[r]:
r += 1
else:
t = min(m, (lst[r] - lst[j]) * (r - j))
lst[j] += t // (r - j)
m -= t
if lst[j] == lst[n - 1]:
return lst[j] + m // (n - j)
re... | FUNC_DEF ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR R... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def get_from_str(string: str):
return list(map(int, string.split(" ")))
def test(string: str):
param, data = string.split("\n")
n, k = get_from_str(param)
numbers = get_from_str(data)
compute(n, k, numbers)
def sort_numbers(list_of_numbers):
return sorted(list_of_numbers)
def find_bigger(n... | FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_DEF VAR ASSIGN VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR RETURN NUMBER IF VAR N... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
a.sort()
median = a[n // 2]
mid = n // 2
if n == 1:
print(a[0] + k)
else:
if k <= a[mid + 1] - a[mid]:
median += k
else:
median = a[mid + 1]
k -= a[mid + 1] - a[mid]
req = 0
f = 2
... | 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 EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
s = 0
c = 1
v = []
for i in range(n // 2 + 1, n):
v.append(c * (l[i] - l[i - 1]))
c += 1
ans = 0
for i in range(len(v)):
if k > 0 and v[i] > 0:
m = min(v[i], k)
ans += m // (i + 1)
k -= m
if k > 0:
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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | from sys import stdin
def check(num, arr, k):
i = len(arr) - 1
while i >= len(arr) // 2:
if arr[i] >= num:
pass
else:
k -= abs(num - arr[i])
i -= 1
if k >= 0:
return True
else:
return False
n, k = list(map(int, stdin.readline().split())... | FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN 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_CA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
a = a[n // 2 :]
n = n // 2 + 1
n_inc = 1
while m > 0:
while n_inc < n and a[n_inc - 1] == a[n_inc]:
n_inc += 1
if n_inc == n:
to_inc = m // n_inc
else:
to_inc = min(m // n_inc, a[n_inc] - a[n_inc - 1]... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMB... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = sorted([int(x) for x in input().split()])[int(n / 2) :]
n = len(a)
l = a[0]
h = a[n - 1] + k // n
ans = 0
def find(m):
moves = 0
for i in range(n):
if m - a[i] > 0:
moves += m - a[i]
if moves > k:
return False
if moves > k:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR F... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
index = n // 2
a.sort()
def f(x):
if a[index] >= x:
return True
tmp = k
for val in a[index:]:
if val >= x:
return True
tmp -= x - val
if tmp < 0:
return False
return True
l = ... | 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 VAR NUMBER EXPR FUNC_CALL VAR FUNC_DEF IF VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR FOR VAR VAR VAR IF VAR VAR RETURN NUMBER VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER RETURN ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
ind = n // 2 + 1
mid = n // 2
median = a[mid]
while ind < n and a[ind] == median:
ind += 1
while k >= ind - mid:
median += 1
k -= ind - mid
while ind < n and a[ind] == median:
ind += 1
print(median) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR VAR VAR VAR VAR VAR NUMBER WHILE VAR BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def f(tar, l, k):
req = 0
for i in range(len(l)):
req += max(0, tar - l[i])
if req <= k:
return True
else:
return False
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
l = l[n // 2 :]
low, high, ans = l[0], 10**18, 0
while low <= high:
mid = lo... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN 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 EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR N... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l.sort()
l = l[n // 2 :]
while k != 0:
mini = l[0]
compte = l.count(mini)
if compte == len(l):
reste = k // len(l)
l[0] += reste
k = 0
break
deux_mini = l[compte]
diff = deux_mini - mini
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR NUMBER VAR AS... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
print(a[0] + k)
else:
a.sort()
n = (n - 1) // 2
a = a[n:]
med = a[0]
for i in range(0, n):
add = min((a[i + 1] - a[i]) * (i + 1), k)
k -= add
med += add // (i + 1)
med += k // (n + 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 IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIG... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def check(x, a):
moves = 0
for i in range(n // 2, n):
if x - a[i] > 0:
moves += x - a[i]
if moves > k:
return False
if moves <= k:
return True
else:
return False
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
a = sorted(a)... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER 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 FUNC_CAL... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | import sys
def main():
import sys
input = sys.stdin.readline
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
arr.append(10**12)
median = arr[n >> 1]
i = n // 2
while i <= n - 1 and arr[i + 1] == median:
i += 1
cnt = i + 1 - n // 2
... | IMPORT FUNC_DEF 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 EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR BIN_O... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
m = [int(a) for a in input().split()]
m.sort()
del m[0 : n // 2]
n = len(m)
a = 1
while k > 0:
if a < n and k - a * (m[a] - m[0]) >= 0:
k = k - a * (m[a] - m[0])
m[0] += m[a] - m[0]
a += 1
else:
m[0] += k // a
k = 0
print(m[0]) | 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 VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
s = list(map(int, input().split()))
s.sort()
t = s[-(n // 2)] - s[n // 2]
if k <= t or n == 1:
print(s[n // 2] + k)
else:
s = s[n // 2 :]
ans = s[0]
t = s[0]
s = list(filter(lambda x: x <= k, map(lambda x: x - t, s)))
t = s[0]
i = 1
while i < len(s) and 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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = sorted(map(int, input().split()))
a += [10**10]
m = (n - 1) // 2
med = 0
sum1 = 0
for i in range(m, n):
sum1 += a[i]
c = min(a[i + 1], (k + sum1) // (i + 1 - m))
if c < a[i]:
break
if c > med:
med = c
print(med) | 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 VAR LIST BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBE... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | length, moves = [int(x) for x in input().split()]
inp = [int(x) for x in input().split()]
middle = int((length + 1) / 2)
ans = int()
sameind = 0
counter = 0
inp.sort()
while moves > sameind:
for i in range(middle + sameind, length):
if inp[i] == inp[middle + sameind - 1]:
sameind += 1
if mid... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR WHILE VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR VAR... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def good(m, a, k):
x = 0
for i in range(n // 2, n):
if m - a[i] > 0:
x += m - a[i]
if x <= k:
return 1
else:
return 0
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = 1
r = 10**11
while r > l + 1:
m = (l + r) // 2
if good(m, ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMB... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m = a[-1]
s = 0
for i in a[n // 2 :]:
s += m - i
if s <= k:
ma = (sum(a[n // 2 :]) + k) // (1 + n // 2)
print(ma)
else:
a = a[n // 2 :]
s = 0
li = 0
for i in range(len(a) - 1):
if (a[i + 1] - a[i]) * (i + 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 EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBE... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
id = n // 2
for i in range(n // 2, n - 1):
if (a[i + 1] - a[i]) * (i + 1 - id) > k:
print(a[i] + k // (i + 1 - id))
return
else:
k -= (a[i + 1] - a[i]) * (i + 1 - id)
print(a[-1] + k // (n - id)) | 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 VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR EXPR FUNC_... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | import sys
input = sys.stdin.readline
n, k = map(int, input().split())
data = list(map(int, input().split()))
data.sort()
data = data[n // 2 :]
now = data[0]
cnt = 0
for i in data:
if k - (i - now) * cnt >= 0:
k -= (i - now) * cnt
else:
break
now = i
cnt += 1
if k > 0:
now += k // c... | 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 EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | from sys import stdin
def ii():
return int(stdin.readline())
def mi():
return map(int, stdin.readline().split())
def li():
return list(mi())
n, k = mi()
m = n // 2
a = li()
a.sort()
p = a[m]
b = []
x = 1
for j in range(m + 1, n):
y = a[j] - p
p += min(y, k // x)
k -= y * x
if k >= 0:... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = [int(i) for i in input().split(" ")]
a = sorted([int(i) for i in input().split(" ")])
ans = a[n // 2]
tot = 0
for i in range(n // 2 + 1, n, 1):
last = tot
tot += (i - n // 2) * (a[i] - a[i - 1])
if tot >= k:
ans = ans + (k - last) // (i - n // 2)
break
ans = a[i]
if tot < k:
a... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m = n // 2
p = m
l = a[p]
while True:
if p < n - 1:
if l < a[p + 1]:
if k < p - m + 1:
print(l)
exit()
k -= p - m + 1
l += 1
else:
p += 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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR WHILE NUMBER IF VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_C... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
m = n // 2
p = a[m]
t = k
c = 1
for i in range(m + 1, n):
d = a[i] - p
r = t - c * d
if r == 0:
print(a[i])
exit()
elif r < 0:
print(a[i - 1] + t // c)
exit()
else:
c += 1
p ... | 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 VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
lo = 0
hi = 2000000000
def check(b, m, x):
size = len(b)
b.sort()
need = 0
for i in range(size // 2, size):
need += max(0, m - b[i])
if k >= need:
return 1
return 0
while lo != hi:
mid = (lo + hi +... | 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 FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER BI... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
def solver(v, p):
for i in range(n // 2, n):
if arr[i] <= v:
t = v - arr[i]
p = p - t
if p >= 0:
return True
else:
return False
start = 1
end = 10**14
while end - start > 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 EXPR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | l = input().split()
n = int(l[0])
k = int(l[1])
l = input().split()
li = [int(i) for i in l]
li.append(1000000000000)
li.sort()
curr = n // 2
slot = 1
ans = li[curr]
while 1:
possible = (li[curr + 1] - li[curr]) * slot
if k >= possible:
ans = li[curr + 1]
curr += 1
slot += 1
k -=... | 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 EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE NUMBER ASSIGN VAR BIN_OP... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(sorted(map(int, input().split())))[n // 2 :]
n = len(a)
def f(x):
return sum(max(0, x - a[i]) for i in range(n))
l, r = a[0], 2 * 10**9 + 2
while r - l > 1:
m = (l + r) // 2
if f(m) <= k:
l = m
else:
r = m
if f(r) <= k:
print(r)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER BIN_OP BIN_OP NUM... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | d = input().split(" ")
d = [int(i) for i in d]
a = input().split(" ")
a = [int(i) for i in a]
a = sorted(a)
def can(m):
sum = 0
for i in range(d[0] // 2, d[0]):
if m > a[i]:
sum += m - a[i]
return d[1] >= sum
l = 0
r = int(1e17)
while r - l > 1:
m = (r + l) // 2
if can(m):
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR VAR VAR BIN_OP VAR VAR VAR RETURN VAR... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | temp = input()
temp = temp.split(" ")
n = int(temp[0])
k = int(temp[1])
temp = input()
temp = temp.split(" ")
a = []
for i in range(n):
a.append(int(temp[i]))
a.sort()
mid = int(n / 2)
move = 0
j = mid
i = mid + 1
while i < n:
if move + (a[i] - a[i - 1]) * (i - mid) <= k:
move = move + (a[i] - a[i - 1])... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | a, b = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
m = a // 2
s = 0
s += A[m]
k = 1
t = True
m += 1
while t == True and m < a:
if A[m] * k - s >= b:
t = False
else:
s += A[m]
k += 1
m += 1
q = A[m - 1] * k
v = q - s
b -= v
e = b // k
print(A[m - 1] + e) | 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 VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER WHILE VAR NUMBER VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
m = a[n // 2]
c = 1
for i in range(n // 2 + 1, n):
if k >= (a[i] - m) * c:
k = k - (a[i] - m) * c
m = a[i]
c = c + 1
else:
m = m + k // c
k = 0
break
print(m + k // c) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, m = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
s.sort()
k = (n - 1) // 2
ind = k + 1
med = s[k]
while m >= 0:
if ind == n:
med += m // (ind - k)
break
m -= (s[ind] - med) * (ind - k)
med = s[ind]
ind += 1
if m < 0:
ind -= 1
med -= -m // (ind - k)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR NUMBER IF VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | from sys import stdin
def iin():
return int(stdin.readline())
def lin():
return list(map(int, stdin.readline().split()))
n, k = lin()
a = lin()
if n == 1:
print(a[0] + k)
else:
a.sort()
h = n // 2
ch1 = 0
ch2 = h + 1
for i in range(h + 1, n):
if (a[i] - a[i - 1]) * (i - h) ... | 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | [n, k] = list(map(int, input().split()))
s = list(map(int, input().split()))
s = sorted(s)
sum = 0
pos = n // 2
for i in range(n // 2, n - 1):
sum = sum + s[n - 1] - s[i]
if k >= sum:
res = s[n - 1] + (k - sum) // (n // 2 + 1)
else:
for i in range(n - 2, n // 2 - 1, -1):
sum = sum - pos * (s[i + 1] ... | ASSIGN LIST 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 BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
q = sorted(map(int, input().split()))[int(n / 2) : n]
median = q[0]
op = 1
for i in range(1, len(q)):
if (q[i] - median) * op <= k:
k -= (q[i] - median) * op
median = q[i]
else:
break
op += 1
print(median + int(k / op)) | 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_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR AS... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
med = a[n // 2]
low = med
high = 2 * 10**9 + 1
while low + 1 < high:
mid = (low + high) // 2
total = 0
for el in a[n // 2 :]:
if el < mid:
total += mid - el
if total > k:
low, high = low, mid
el... | 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 VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER A... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
mid = n // 2
itr = 1
tot = 0
for i in range(mid + 1, n):
if tot + (arr[i] - arr[i - 1]) * itr > k:
break
else:
tot += (arr[i] - arr[i - 1]) * itr
itr += 1
final = arr[mid + itr - 1] + (k - tot) // itr
print... | 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 VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
s = n // 2
l = 1
r = int(10000000000.0)
while l < r:
m = (l + r + 1) // 2
cnt = 0
for i in range(s, n):
cnt += max(0, m - a[i])
if cnt <= k:
l = m
else:
r = m - 1
print(l) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | import sys
input = sys.stdin.readline
n, k = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)
MIN = 1
MAX = max(A) + k
while MIN != MAX:
AVE = (MIN + MAX + 1) // 2
score = 0
for i in range(n // 2 + 1):
if AVE > A[i]:
score += AVE - A[i]
if score > k:
... | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR B... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
mid = n // 2
def predicate(x):
add = 0
for i in range(mid, n):
add += max(x - arr[i], 0)
return add <= k
def bs(start, end):
ans = None
while start <= end:
mid = start + end >> 1
if predicat... | 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 VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR NONE WHILE V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
a.sort()
a = a[n // 2 :] + [10**10]
for i in range(1, len(a)):
prev = a[i - 1]
curr = a[i]
if (curr - prev) * i <= k:
a[0] = curr
k -= (curr - prev) * i
else:
val = k // i
a[0] += val
b... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER LIST BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF BIN_OP BIN_OP V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = sorted(map(int, input().split()))[n // 2 :]
i = 0
s = 0
while i < len(a):
s += a[i]
if a[i] * (i + 1) - s > k:
break
i += 1
k -= a[i - 1] * i - sum(a[:i])
print(a[i - 1] + k // i) | 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 BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = list(map(int, input().split()))
arr = sorted(list(map(int, input().split())))
median = arr[n // 2]
jumps = []
for i in range(n // 2 + 1, n):
jumps.append(arr[i] - arr[i - 1])
for i in range(len(jumps)):
weight = i + 1
if weight * jumps[i] > k:
this_jump = k // weight
median += this_ju... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FOR V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
r = k
m = (n - 1) // 2
p = m + 1
v = a[m]
while p < n:
u = (p - m) * (a[p] - v)
if u <= r:
v = a[p]
r -= u
else:
break
p += 1
d = r // (p - m)
u = d * (p - m)
r -= u
v = v + d
print(v) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
i = 0
s = 0
d = n // 2 + 1
res = l[n // 2]
for j in range(n // 2 + 1, n):
i += 1
if k >= i * (l[j] - l[j - 1]):
s += i * (l[j] - l[j - 1])
k -= i * (l[j] - l[j - 1])
res += l[j] - l[j - 1]
else:
d =... | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR NUM... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
u = list(map(int, input().split()))
u.sort()
if n == 1:
print(u[0] + k)
exit()
ans = u[n // 2]
num = 1
for i in range(n // 2 + 1, n):
if (u[i] - u[i - 1]) * (i - n // 2) <= k:
k -= (u[i] - u[i - 1]) * (i - n // 2)
ans = u[i]
num += 1
else:
... | 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 IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBE... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | import sys
n, k = list(map(int, sys.stdin.readline().strip().split()))
a = list(map(int, sys.stdin.readline().strip().split()))
m = n // 2
a.sort()
d = 1
ans = a[m]
if ans != a[n - 1]:
while ans == a[m + d]:
d = d + 1
else:
d = n // 2 + 1
while d <= k and k > 0:
k = k - d
ans = ans + 1
if a... | IMPORT ASSIGN VAR VAR FUNC_CALL 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 BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR BIN_OP VAR VAR ASSIGN VAR B... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = [int(a) for a in input().split()]
a = list(map(int, input().split()))
m = n // 2
a.sort()
l = 1
r = int(2000000000.0)
while l != r:
mid = (l + r + 1) // 2
tmp = 0
for i in range(m, n):
if mid - a[i] > 0:
tmp += mid - a[i]
if tmp > k:
r = mid - 1
if tmp <= k... | 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 VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
md = n // 2
lo = l[md]
hi = int(10000000000.0)
ans = l[md]
while lo <= hi:
mid = (lo + hi) // 2
reqk = 0
for i in range(n // 2, n):
if l[i] < mid:
reqk += mid - l[i]
if reqk <= k:
ans = mid
... | 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 VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
same = 1
mid = n // 2
while k > 0:
if same <= mid:
diff = l[mid + same] - l[mid]
temp = k
k -= diff * same
if k >= 0:
l[mid] = l[mid + same]
else:
l[mid] = l[mid] + temp // s... | 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 NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def binarySearch(arr, l, r, x):
mid = int(l + (r - l) / 2)
if r >= l:
if arr[mid] == x:
return mid
elif arr[mid] > x:
return binarySearch(arr, l, mid - 1, x)
else:
return binarySearch(arr, mid + 1, r, x)
else:
return mid
les, k = list(map... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR 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 BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def check(mid):
ans = 0
for i in range(n // 2 + 1):
ans += max(0, mid - a[i])
if ans <= k:
return True
return False
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
l, r = 1, 10**10
while l != r:
mid = (l + r + 1) // 2
if check(mid):
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.append(10**57)
m = n // 2
for i in range(m, n):
p = (i - m + 1) * (a[i + 1] - a[i])
if k < p:
break
k -= p
print(a[i] + k // (i - m + 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 EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def possible(l, mid, k, n):
add = 0
for i in range(n // 2, n):
if mid - l[i] > 0:
add += mid - l[i]
if add > k:
return 1
if add <= k:
return 0
else:
return 1
n, m = map(int, input().split())
l = list(map(int, input().split()))
low = 1
hig... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER RETURN 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 VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
st = n // 2
cur = arr[st]
cnt = 1
f = 0
for i in range(st + 1, n):
diff = arr[i] - cur
if diff * cnt <= k:
k -= diff * cnt
cnt += 1
cur = arr[i]
else:
f = 1
break
if f == 0:
cu... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BI... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().strip().split())
numbers = list(map(int, input().strip().split()))
numbers.sort()
p = numbers[n // 2]
s = 0
t = 0
for i in range(n // 2, n - 1):
p1 = (k - s) // (i - n // 2 + 1)
s = s + min(p1, numbers[i + 1] - p) * (i - n // 2 + 1)
t = t + min(p1, numbers[i + 1] - p)
if p1 < num... | 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 EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort()
idxAns = int(n / 2)
ans = arr[idxAns]
while k > 0:
idx = idxAns + 1
while idx < n:
if ans != arr[idx]:
break
idx += 1
if idx == n:
x = n - idxAns
ans += int(k / x)
k = ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR ASSI... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
arr = list(map(int, input().split()))
if n == 1:
print(arr[0] + k)
exit(0)
arr.sort()
mid = n // 2
piv = mid + 1
maxm = arr[mid]
delta = arr[mid + 1] - arr[mid]
while k >= delta:
k -= delta
maxm = arr[piv]
piv += 1
if piv >= n:
break
delta = (piv - mi... | 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 VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP V... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = list(map(int, input().split()))
ai = list(map(int, input().split()))
ai.sort()
num = n // 2
num2 = num
ans = ai[num]
n2 = n - 1
while num != n2 and k > 0:
num += 1
k -= (ai[num] - ai[num - 1]) * (num - num2)
if k < 0:
print(ai[num] + k // (num - num2))
else:
print(ai[num] + k // (num - num2 + 1)) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR BIN_O... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | from sys import exit, stdin, stdout
n, k = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
a.sort()
a = a[(n - 1) // 2 :]
sums = [0]
total = 0
for i in range((n + 1) // 2):
total += a[i]
sums.append(total)
def doable(tgt):
if a[0] >= tgt:
return True
ct = 0
... | 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 VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | from sys import stdin, stdout
N, K = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]
arr.sort()
half = N // 2
s = sum(arr[half:])
bound = s + K
res = 0
for i in range(N - 1, N // 2 - 1, -1):
if bound // (i - half + 1) > arr[i]:
res = max(res, bound // (i - half +... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBE... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = 1
jog = 0
ans = 0
if n == 1:
print(a[0] + k)
else:
for i in range(int((n - 1) / 2), n - 1):
jog += l * (a[i + 1] - a[i])
if jog > k:
jog -= l * (a[i + 1] - a[i])
ans = a[i] + int((k - jog) /... | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | def f(v, mid, N, K):
last_max = v[N // 2] + mid
cur = K - mid
for i in range(N // 2 + 1, N):
needed = last_max - v[i]
if needed > 0:
cur -= needed
if cur < 0:
return False
else:
break
return True
def main():
N, K = map(int... | FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = list(map(int, input().split()))[:2]
a = list(map(int, input().split()))
a = sorted(a)
b = a[n // 2 :]
diff = []
for i in range(1, len(b)):
di = i * (b[i] - b[i - 1])
diff.append(di)
ans = b[0]
for i in range(len(diff)):
if k < diff[i]:
ans = ans + k // (i + 1)
k = 0
break
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VA... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = map(int, input().split())
s = sorted(list(map(int, input().split())))
s[0 : n // 2] = []
med = 0
if n == 1:
print(s[0] + k)
else:
i = 0
while k > (i + 1) * (s[i + 1] - s[i]):
k = k - (i + 1) * (s[i + 1] - s[i])
i += 1
if i == n // 2:
break
med = s[i] + k // (i ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER LIST ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR BIN_... |
You are given an array $a$ of $n$ integers, where $n$ is odd. You can make the following operation with it: Choose one of the elements of the array (for example $a_i$) and increase it by $1$ (that is, replace it with $a_i + 1$).
You want to make the median of the array the largest possible using at most $k$ operatio... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
mid = n // 2
count = 1
Sum = a[mid]
res = a[mid]
index = -1
for i in range(mid + 1, n):
if count * a[i] - Sum <= k:
count += 1
Sum += a[i]
res = a[i]
else:
index = i
break
if index == -1:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.