description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
A = sorted(list(map(int, input().split())))
list.reverse(A)
Sum = 0.0
Ans = 0.0
for i in range(n):
Sum += A[i]
t = n - i - 1
if m >= n - i - 1:
Ans = max(Ans, (Sum + min(m - t, (i + 1) * k)) / (i + 1))
print(Ans) | ASSIGN VAR 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 EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
total = sum(a)
avgs = []
for i in range(0, n):
remain = max(m - i, 0)
ln = n - i
each = remain // ln
sm = 0
if each >= k:
sm = total / ln + k
else:
sm = (total + remain) / ln
avgs.append(sm)
total -= a[i]
if remain == 0:
break
print(max(avgs)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
max_avg = 0
total = sum(a)
while n > 0 and m > -1:
tmp = (total + min(n * k, m)) / n
if max_avg < tmp:
max_avg = tmp
total -= a.pop()
n -= 1
m -= 1
print(max_avg) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | num_heros, opt_ph, tot_opt = map(int, input().split(" "))
pList = list(map(int, input().split(" ")))
pList = sorted(pList)
pLen = len(pList)
tot_sum = sum(pList)
max_val = 0
x = 0
while x < pLen and x <= tot_opt:
val = (tot_sum + min(tot_opt - x, (pLen - x) * opt_ph)) / (pLen - x)
if val > max_val:
max_val = val
tot_sum -= pList[x]
x += 1
print(max_val) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
Sum = sum(a)
max_avg = Sum / n
a = sorted(a)
if m > n:
if m - n >= k and max_avg < a[-1] + k:
max_avg = a[-1] + k
else:
max_avg = a[-1] + m - n + 1
elif m == n:
if max_avg < a[-1] + 1:
max_avg = a[-1] + 1
else:
if max_avg < (Sum + m) / n:
max_avg = (Sum + m) / n
for i in range(m):
Sum -= a[i]
max_avg = max(max_avg, (Sum + min(m - i - 1, k * (n - 1 - i))) / (n - i - 1))
print(max_avg) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR VAR IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | [n, k, m] = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
s = sum(a)
res = [(s + min(n * k, m)) / n]
for i in range(1, n):
s -= a[i - 1]
if m < i:
break
res.append((s + min(m - i, (n - i) * k)) / (n - i))
print(max(res)) | ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
l.reverse()
if m > n - 1:
print(l[0] + min(m - (n - 1), k))
else:
sum = l[0]
for i in range(1, n - m):
sum += l[i]
ans = sum / (n - m)
j = 1
for i in range(n - m, n):
sum += l[i]
if ans < (sum + j) / (n - m + j):
ans = (sum + j) / (n - m + j)
j += 1
if k * (n - m + j) < j:
break
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR IF VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER IF BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = list(map(int, input().split()))
ai = list(map(int, input().split()))
ai.sort()
n2 = n
num = sum(ai)
ans = 0.0
i = 0
while n2 > 0 and m > -1:
num2 = (num + min(m, n2 * k)) / n2
ans = max(ans, num2)
num -= ai[i]
i += 1
n2 -= 1
m -= 1
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | import sys
def max_average(H, N, K, M):
def prefix_sum():
presum = [0]
s = 0
for e in H:
s = s + e
presum.append(s)
return presum
SH = prefix_sum()
avgs = [
((SH[N] - SH[i] + min(M - i, K * (N - i))) / (N - i))
for i in range(min(M + 1, N))
]
return max(avgs)
def main():
N, K, M = tuple(int(x) for x in input().split(" "))
H = sorted(tuple(int(h) for h in input().split(" ")))
print(max_average(H, N, K, M))
main() | IMPORT FUNC_DEF FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | a = [int(i) for i in input().split()]
n = a[0]
k = a[1]
m = a[2]
a = [int(i) for i in input().split()]
sum_a = sum(a)
def boost(q, energy):
max_boost = energy
if max_boost > k * q:
max_boost = k * q
return max_boost
max_boost = boost(n, m)
average = (sum_a + max_boost) / n
people = n
energy = m
a.sort()
for i in range(n):
if people - 1 != 0 and energy - 1 != -1:
max_boost = boost(people - 1, energy - 1)
tmp_average = (sum_a - a[i] + max_boost) / (people - 1)
if average <= tmp_average:
energy -= 1
people -= 1
sum_a -= a[i]
average = tmp_average
print(average) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | import sys
input = sys.stdin.readline
def main():
n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if m == 1 and m != n:
return max(sum(a[m:]) / (n - m), (sum(a) + 1) / n)
if m > n:
m -= n - 1
return max(a) + min(k, m)
if m == n:
if n == 1:
return max(a) + min(k, m)
return max(a)
q = set(a)
l = len(q)
cur = n
cur_2 = m
for i in range(len(a)):
if l == 1 or cur_2 == 0:
break
else:
q.discard(a[i])
l -= 1
cur -= 1
cur_2 -= 1
if l == 1 and cur_2 != 0:
return q.pop() + cur_2 / cur
return sum(a[m:]) / (n - m)
print("{0:8f}".format(main())) | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR VAR RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR IF VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | def superhero_problem():
n, k, m = input().split(" ")
tmp = input().split(" ")
n, k, m = int(n), int(k), int(m)
sum = 0
for i, _ in enumerate(tmp):
tmp[i] = int(tmp[i])
sum += tmp[i]
tmp = sorted(tmp)
a = [0]
a.extend(tmp)
answer = (sum + min(n * k, m)) / n
for i in range(1, n):
op = m - i
sum -= a[i]
if op < 0:
break
answer = max(answer, (sum + min((n - i) * k, op)) / (n - i))
print(answer)
return
superhero_problem() | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
r = min(m, n - 1)
s = sum(a)
ans = (s + min(m, k * n)) / n
for i in range(0, r):
s -= a[i]
t = (s + min(m - i - 1, k * (n - i - 1))) / (n - i - 1)
ans = max(t, ans)
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
lst = [*map(int, input().split())]
summa = sum(lst)
res = 0
lst.sort()
for i, x in enumerate(lst):
if m < 0:
break
new = (summa + min(n * k, m)) / n
summa -= x
n -= 1
m -= 1
if new < res:
break
res = new
print(res) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | def get():
return list(map(int, input().split()))
n, k, m = get()
a = get()
a.sort()
c = (n + 1) * [0]
c[0] = 0
for i in range(1, n + 1):
c[i] = c[i - 1] + a[i - 1]
f = (c[n] - c[0] + min(m, n * k)) / n
for i in range(1, n):
if m - i >= 0:
f = max((c[n] - c[i] + min(m - i, (n - i) * k)) / (n - i), f)
print(f) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER LIST NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
suml = sum(l)
mean = 0
if n * k > m:
maxIncrease = m
else:
maxIncrease = n * k
mean = (suml + maxIncrease) / n
sumP = suml
maxIncrease = 0
for i in range(1, min(n - 1, m) + 1):
if (n - i) * k > m - i:
maxIncrease = m - i
else:
maxIncrease = (n - i) * k
sumP = sumP - l[i - 1]
mean = max(mean, (sumP + maxIncrease) / (n - i))
print(mean) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
s = [int(x) for x in input().split()]
S = sorted(s)
S = S[::-1]
dp = [S[0]]
for i in range(1, len(s)):
dp.append(dp[-1] + S[i])
dp = dp[::-1]
br = len(dp)
for i in range(0, len(dp)):
if i <= m:
dp[i] = dp[i] + min(m - i, (n - i) * k)
else:
br = i
break
dp = dp[:br]
ans = -1
for i in range(0, len(dp)):
ans = max(ans, dp[i] / (n - i))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = [int(x) for x in input().split(" ")]
s = [int(x) for x in input().split(" ")]
res = 0
somme = 0
s.sort(reverse=True)
j = m
while len(s) > 1 and j > 0 and (s[0] - s[-1] > 1 or j > len(s)):
s.pop()
j = j - 1
x1 = s.count(max(s))
x2 = s.count(min(s))
if x1 >= x2 and max(s) - min(s) != 0 and j > 0:
s.pop()
j = j - 1
somme = sum(s)
y = len(s)
while j > 0 and y > 0:
if j >= k:
somme = somme + k
j = j - k
y = y - 1
else:
somme = somme + j
break
res = somme / len(s)
print(res) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR WHILE FUNC_CALL VAR VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
sm = 0
ans = 0
for i in range(len(arr) - 1, -1, -1):
sm += arr[i]
if i <= m:
sm += min(k * (n - i), m - i)
ans = max(ans, sm / (n - i))
sm -= min(k * (n - i), m - i)
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER VAR VAR VAR IF VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | def main():
n, k, m = map(int, input().split())
heroes = [x for x in map(int, input().split())]
heroes.sort()
cbk = min(m, n)
m -= cbk
for i in range(cbk):
heroes[i] += 1
heroes.reverse()
for i in range(n):
used = min(m, k - 1)
heroes[i] += used
m -= used
pf, tot = [], 0
for i in range(n):
tot += heroes[i]
pf += [tot]
ave = [(pf[i] / (i + 1)) for i in range(n)]
print(max(ave[-min(n, cbk + 1) :]))
main() | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR LIST VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in a:
s += i
a = sorted(a)
ans = (s + min(n * k, m)) / n
p = n
for i in range(n - 1):
s -= a[i]
m -= 1
p -= 1
ans = max(ans, (s + min(p * k, m)) / p)
if m == 0:
break
print("%.10f" % ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = input().split()
n = int(n)
k = int(k)
m = int(m)
a = input().split()
s = 0
for i in range(len(a)):
a[i] = int(a[i])
s += a[i]
a.sort()
ans = (s + min(k * n, m)) / n
for i in range(n - 1):
if i == m:
break
s -= a[i]
ans = max(ans, (s + min(k * (n - i - 1), m - i - 1)) / (n - i - 1))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | from sys import stdin
n, m, k = list(map(int, stdin.readline().strip().split()))
s = list(map(int, stdin.readline().strip().split()))
s.sort()
acum = [0]
for i in range(n - 1, -1, -1):
acum.append(acum[-1] + s[i])
acum.reverse()
acum.pop()
y = min(n * m, k)
ans = (sum(s) + y) / n
for i in range(min(n - 1, k)):
k -= 1
y = min((n - i - 1) * m, k)
ans = max(ans, (acum[i + 1] + y) / (n - i - 1))
print(ans) | ASSIGN VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | nheroes, ninc, nops = map(int, input().split())
pows = [p for p in map(float, input().split())]
total_pow = sum(pows)
max_avg = float("-inf")
pows.sort()
for i in range(min(nheroes, nops)):
max_inc = min(nheroes * ninc, nops - i)
new_max = (total_pow + max_inc) / nheroes
max_avg = max(max_avg, new_max)
total_pow -= pows[i]
nheroes -= 1
if nheroes >= 1:
print(max(max_avg, total_pow / nheroes))
else:
print(max_avg) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | def __solve__():
a = input().split()
n = int(a[0])
k = int(a[1])
m = int(a[2])
a = input().split()
i = 0
sum = 0
for j in range(n):
a[i] = int(a[i])
sum += a[i]
i += 1
a.sort(key=None, reverse=False)
res = sum / n
cnt = min(n - 1, m)
for j in range(cnt + 1):
if j != 0:
sum -= a[j - 1]
add = min(k * (n - j), m - j)
now = sum + add
now /= n - j
res = max(res, now)
print(res)
__solve__() | FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NONE NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | def my_min(x, y):
if x > y:
return y
return x
def my_max(x, y):
if x > y:
return x
return y
input1 = input().split(" ")
a = input().split(" ")
n = int(input1[0])
k = int(input1[1])
m = int(input1[2])
Sum = 0
a_l = len(a)
for i in range(a_l):
a[i] = int(a[i])
Sum += a[i]
a.sort()
r = my_min(n - 1, m)
ans = (Sum + my_min(m, n * k)) / n
for i in range(r):
Sum -= a[i]
ans = my_max(ans, (Sum + my_min(m - i - 1, k * (n - i - 1))) / (n - i - 1))
print(ans) | FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
s = r = 0
a = list(map(int, input().split()))
a.sort()
if m >= n:
print(a[n - 1] + min(m - n + 1, k))
else:
for i in range(0, n):
s += a[i]
s += m
r = s / n
for i in range(0, m):
r = max(r, (s - a[i] - i - 1) / (n - i - 1))
s -= a[i]
print(r) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
A = sorted(list(map(int, input().split())))
sum_ = sum(A)
res = (sum(A) + min(m, n * k)) / n
for i in range(min(m, n - 1)):
sum_ -= A[i]
min_ = min(m - 1, (n - i - 1) * k)
res = max(res, (sum_ + min_) / (n - i - 1))
m -= 1
print(res) | ASSIGN VAR 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 FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
sumi = sum(a)
ans = sumi / n
ct = 0
add = min(k * n, m - ct)
ans = max(ans, (sumi + add) / n)
for i in a:
sumi -= i
ct += 1
n -= 1
if ct > m or n == 0:
break
add = min(k * n, m - ct)
ans = max(ans, (sumi + add) / n)
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR FOR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | input1 = input().split(" ")
input2 = input().split(" ")
member = int(input1[0])
limit = int(input1[1])
operation = int(input1[2])
power = []
for i in range(member):
power.append(int(input2[i]))
power.sort()
Sum = sum(power)
maximum = (Sum + (limit * member if limit * member < operation else operation)) / member
for i in range(operation):
Sum -= power[i]
member -= 1
if member == 0:
break
temp = (
Sum
+ (limit * member if limit * member < operation - i - 1 else operation - i - 1)
) / member
if temp > maximum:
maximum = temp
print(maximum) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR 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 VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | import sys
n, k, m = [int(tmp) for tmp in sys.stdin.readline().split()]
a = [int(tmp) for tmp in sys.stdin.readline().split()]
a.sort(reverse=True)
sa = sum(a)
mr = m
nr = n
sar = sa
while nr >= 2 and mr != 0:
avsidau = (sar - a[nr - 1] + min([mr - 1, (nr - 1) * k])) / (nr - 1)
avsiu = (sar + min([nr * k, mr])) / nr
if avsidau > avsiu:
mr -= 1
nr -= 1
sar -= a[nr]
else:
break
sar += min([nr * k, mr])
avs = sar / nr
print(avs) | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR LIST BIN_OP VAR VAR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR LIST BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
sm = 0
cl = [0]
for x in a:
sm += x
cl.append(sm)
def func(i):
return (cl[-1] - cl[i] + min(k * (n - i), m - i)) / (n - i)
mx = 0
for i in range(min(n - 1, m) + 1):
res = func(i)
if res > mx:
mx = res
print(mx) | ASSIGN VAR 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 NUMBER ASSIGN VAR LIST NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
sm = sum(a)
ans = (sm + min(n * k, m)) / n
i = 0
while True:
if i == n - 1 or i == m:
break
sm -= a[i]
tans = (sm + min(m - i - 1, (n - i - 1) * k)) / (n - i - 1)
if tans < ans:
break
ans = tans
i += 1
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
d = [0]
for i in range(n):
d.append(d[-1] + a[i])
ans = d[n] / n
for i in range(min(n, m + 1)):
ans = max(ans, (d[n] - d[i] + min((n - i) * k, m - i)) / (n - i))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | read = lambda: map(int, input().split())
n, k, m = read()
a = list(read())
a.sort()
x = sum(a)
suma = [x]
for i in range(min(m, n - 1)):
x -= a[i]
suma.append(x)
mm = 0
for cnt, i in enumerate(suma):
mm = max(mm, (i + min(m - cnt, k * (n - cnt))) / (n - cnt))
print("%.10f" % mm) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort(reverse=True)
for i in range(1, len(a)):
a[i] += a[i - 1]
for i in range(n):
if n - 1 - i <= m:
a[i] = float(a[i] + min(m - (n - 1 - i), k * (i + 1))) / (i + 1)
print(max(a[max(n - 1 - m, 0) :])) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
s = sum(a)
ans = -1
for i in range(min(n, m + 1)):
avg = (s + min(k * (n - i), m - i)) / (n - i)
ans = max(avg, ans)
s -= a[0]
del a[0]
print(ans) | ASSIGN VAR 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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | def check(sumPower, heroesAmount, operations, k):
return (sumPower + min(heroesAmount * k, operations)) / heroesAmount
def maxPower():
n, k, m = map(int, input().split())
if n == 0:
print(0.0)
return
array = sorted(list(map(int, input().split())))
sumPower = 0
heroesAmount = n
for i in array:
sumPower += i
maxMidPower = check(sumPower, heroesAmount, m, k)
for i in range(0, len(array) - 1):
sumPower -= array[i]
heroesAmount -= 1
m -= 1
maxMidPower = max(maxMidPower, check(sumPower, heroesAmount, m, k))
if m == 0:
break
return maxMidPower
print(maxPower()) | FUNC_DEF RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR FUNC_CALL VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
sum = 0
for i in l:
sum += i
if n * k < m:
avg, i = (sum + n * k) / n, 0
else:
avg, i = (sum + m) / n, 0
while m and n != 1:
m = m - 1
n = n - 1
if n * k < m:
temp = (sum - l[i] + n * k) / n
sum = sum - l[i]
else:
temp = (sum - l[i] + m) / n
sum = sum - l[i]
i = i + 1
if temp > avg:
avg = temp
print(avg) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort(reverse=True)
l = min(a)
s = sum(a)
max_s = 0
while m > 0 and a:
max_s = max((s + min(m, k * len(a))) / len(a), max_s)
s -= a.pop()
m -= 1
if a:
max_s = max((s + min(m, k * len(a))) / len(a), max_s)
print(max_s) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
ls = sorted(list(map(int, input().split())), reverse=True)
s = sum(ls)
avg = (min(len(ls) * k, m) + s) / len(ls)
while len(ls) > 1 and m > 0:
s -= ls.pop(-1)
m -= 1
z = (min(len(ls) * k, m) + s) / len(ls)
if z > avg:
avg = z
print(avg) | ASSIGN VAR 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 FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a = list(sorted(a))
s = [0] * n
s[0] = a[0]
for i in range(1, n):
s[i] = s[i - 1] + a[i]
S = s[n - 1]
R = (S + min(k * n, m)) / n
for i in range(min(m, n - 1)):
S = s[n - 1] - s[i]
R = max((S + min(m - i - 1, k * (n - i - 1))) / (n - i - 1), R)
print(R) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
a.sort()
i = 0
max_s = (s + min(m, n * k)) / n
while m > 0 and i < n - 1:
s -= a[i]
m -= 1
i += 1
max_s = max(max_s, (s + min(m, (n - i) * k)) / (n - i))
print(max_s) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(sorted(map(int, input().split()), reverse=True))
best_avg = 0
s = sum(a)
for i in range(len(a)):
if i > m:
break
if i > 0:
s -= a[-i]
best_avg = max(best_avg, (s + min((len(a) - i) * k, m - i)) / (len(a) - i))
print(best_avg) | ASSIGN VAR 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 NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | import sys
input = sys.stdin.readline
n, k, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
SUM = sum(A)
ANS = 0
for i in range(min(n, m + 1)):
MPOWER = SUM + min(m - i, (n - i) * k)
ANS = max(ANS, MPOWER / (n - i))
SUM -= A[i]
print(ANS) | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | def operation(a, last_index, sum_before_last_index, operation_index):
if last_index == 0:
a[0] += 1
return last_index, sum_before_last_index
if sum_before_last_index >= last_index * (a[last_index] + 1):
return last_index - 1, sum_before_last_index - a[last_index - 1]
else:
a[operation_index] += 1
return last_index, sum_before_last_index
def foo(n, k, m, a):
if n == 1:
return a[0] + min(k, m)
last_index = n - 1
sum_before_last_index = sum(a[:last_index])
i = 0
j = 0
operation_index = 0
while operation_index <= last_index and i < m:
prev = last_index
last_index, sum_before_last_index = operation(
a, last_index, sum_before_last_index, operation_index
)
i += 1
if prev == last_index:
j += 1
if j % k == 0:
operation_index += 1
return sum(a[: last_index + 1]) / (last_index + 1)
def foo2(n, k, m, a):
sum_del_i = sum(a)
mx = (sum_del_i + min(m, n * k)) / n
for i in range(1, min(n, m + 1)):
sum_del_i = sum_del_i - a[i - 1]
mx = max(mx, (sum_del_i + min(m - i, (n - i) * k)) / (n - i))
return mx
n, k, m = [int(x) for x in input().split()]
a = [int(i) for i in input().split()]
a.sort()
print(foo2(n, k, m, a)) | FUNC_DEF IF VAR NUMBER VAR NUMBER NUMBER RETURN VAR VAR IF VAR BIN_OP VAR BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER RETURN VAR VAR FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = list(map(int, input().split()))
a = [int(x) for x in input().split()]
a.sort(reverse=True)
ans = 0
s = 0
for i in range(n):
s += a[i]
if n - i - 1 > m:
continue
ans = max(ans, float((s + min(m - (n - i - 1), (i + 1) * k)) / (i + 1)))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i in range(n - 2, -1, -1):
a[i] = a[i] + a[i + 1]
max_num = (a[0] + min(k * n, m)) / n
for i in range(1, n):
if i > m:
break
res = (a[i] + min((n - i) * k, m - i)) / (n - i)
max_num = max(max_num, res)
print(max_num) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
v = list(map(int, input().split()))
r = s = i = 0
for x in reversed(sorted(v)):
i += 1
s += x
if n - i <= m:
r = max(r, (s + min(k * i, m - n + i)) / i)
print(r) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | import sys
n, k, m = [int(i) for i in input().split(" ")]
def helper(pows, k, m):
res = -sys.maxsize
pref = [0]
for i in range(len(pows)):
pref.append(pref[-1] + pows[i])
if len(pows) == 1:
return pows[0] + k
for i in range(min(len(pows), m + 1)):
total = m - i
if (len(pows) - i) * k <= total:
res = max(res, (pref[-1] - pref[i] + (len(pows) - i) * k) / (len(pows) - i))
else:
res = max(res, (pref[-1] - pref[i] + total) / (len(pows) - i))
return res
pows = [int(i) for i in input().split(" ")]
pows.sort()
print(helper(pows, k, m)) | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | from sys import stdin
n, k, m = map(int, input().split())
l = list(map(int, stdin.readline().split()))
l.sort()
l1 = []
sm = 0
for i in l:
sm += i
l1.append(sm)
l2 = []
for i in range(0, min(n - 1, m)):
l2.append((l1[-1] - l1[i] + min(k * (n - i - 1), m - i - 1)) / (n - i - 1))
l2.append((sum(l) + min(n * k, m)) / n)
print(max(l2)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
s = sum(arr)
mx = s / n + min(m, n * k) / n
for i in range(n - 1):
remain = m - i - 1
val = (s - arr[i]) / (n - (i + 1)) + min(remain, (n - i - 1) * k) / (n - i - 1)
s -= arr[i]
if val > mx:
mx = val
if remain == 0:
break
print(mx) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = [int(s) for s in input().split()]
a.sort()
q = sum(a)
ans = 0
for i in range(min(n, m + 1)):
if m - i >= (n - i) * k:
ans = max(ans, (q + (n - i) * k) / (n - i))
else:
ans = max(ans, (q + m - i) / (n - i))
q -= a[i]
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if n == 1:
print(a[0] + min(m, k))
exit()
pr = [(0) for i in range(n + 1)]
pr[0] = 0
mx = 0
eps = 1e-07
for i in range(1, n + 1):
pr[i] = pr[i - 1] + a[i - 1]
for c in range(max(n - m, 1), n + 1):
l = n - c
if (pr[c] + min(c * k, m - n + c)) / c - mx > eps:
mx = (pr[c] + min(c * k, m - l)) / c
print(mx) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = list(map(int, input().split()))
a = sorted(map(int, input().split()))
res = 0
sm = sum(a)
for ai in a:
if m < 0:
break
if m < k * n:
alt = (sm + m) / n
else:
alt = sm / n + k
res = max(res, alt)
n -= 1
m -= 1
sm -= ai
print(res) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | vals = [int(r) for r in input().split()]
n = vals[0]
k = vals[1]
m = vals[2]
powers = sorted([int(r) for r in input().split()], reverse=True)
ans = 0
curr_sum = 0
for i in range(n):
curr_sum += powers[i]
if n - 1 - i > m:
continue
else:
moves_left = m - (n - 1 - i)
ppl_left = i + 1
ans = max(ans, (curr_sum + min(moves_left, ppl_left * k)) / ppl_left)
print("{0:.20f}".format(ans)) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
s = sum(a)
if m <= k * n:
ans = (s + m) / n
else:
ans = (s + k * n) / n
for i in range(min(n - 1, m)):
s = s - a[i]
m -= 1
if m <= k * (n - i - 1):
t = (s + m) / (n - i - 1)
else:
t = (s + k * (n - i - 1)) / (n - i - 1)
if t > ans:
ans = t
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n_super, max_increase, max_op = list(map(int, input().strip().split()))
powers = list(map(int, input().strip().split()))
powers = sorted(powers)
curr_sum = sum(powers)
best_score = float("-inf")
for idx in range(n_super):
n_remaining_hero = n_super - idx
n_remaining_actions = max_op - idx
if n_remaining_actions < 0:
break
this_score = curr_sum / n_remaining_hero + min(
max_increase, n_remaining_actions / n_remaining_hero
)
if this_score > best_score:
best_score = this_score
curr_sum -= powers[idx]
print(best_score) | ASSIGN VAR 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 FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
L.sort(reverse=True)
T = [0]
for i in range(n):
T.append(T[-1] + L[i])
best = 0
for i in range(1, n + 1):
if n - i <= m:
best = max(best, (T[i] + min(m - n + i, k * i)) / i)
print(best) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = sum(a) / n
cm = [a[0]]
for i in range(1, n):
cm.append(cm[-1] + a[i])
cm.append(0)
for d in range(min(n, m + 1)):
nb = min((m - d) // k, n - d)
r = (m - d) % k if nb < n - d else 0
ans = max(ans, (cm[-2] - cm[d - 1] + nb * k + r) / (n - d))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, m, k = [int(x) for x in input().split()]
sup = [int(x) for x in input().split()]
summa = 0
sup.sort()
total = []
counter = len(sup)
flag = False
for item in sup:
summa += item
a = (summa + min(m * counter, k)) / counter
total.append(a)
for item in sup:
k -= 1
if k >= 0:
if counter > 1:
summa -= item
counter -= 1
a = (summa + min(m * counter, k)) / counter
total.append(a)
else:
a = (summa + min(m * counter, k)) / counter
total.append(a)
print(max(total)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
me = arr[n - 1]
ind = 0
sarr = [(0) for i in range(n + 1)]
for i in range(n - 1, -1, -1):
sarr[i] = sarr[i + 1] + arr[i]
ans = (sarr[0] + min(m, n * k)) / n
for i in range(min(m, n - 1)):
temp = sarr[i + 1] + min(m - 1 - i, (n - 1 - i) * k)
temp = temp / (n - 1 - i)
ans = max(ans, temp)
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, lim, total = map(int, input().split())
a = sorted(map(int, input().split()))
psums = [0, a[0]]
for i in range(1, n):
psums.append(psums[i] + a[i])
def rangeSum(left, right):
return psums[right + 1] - psums[left]
ret = 0
for nDel in range(min(total + 1, n)):
rem = n - nDel
power = (min(rem * lim, total - nDel) + rangeSum(nDel, n - 1)) / rem
ret = max(ret, power)
print(ret) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_DEF RETURN BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | import sys
input = sys.stdin.readline
for _ in range(1):
n, k, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
som = sum(l)
rem = m // k
rem_dash = m % k
ans = (som + min(n * k, rem * k + rem_dash)) / n
cnt = n
for i in range(min(n - 1, m)):
m -= 1
som -= l[i]
cnt -= 1
rem = m // k
rem_dash = m % k
ans = max((som + min(cnt * k, rem * k + rem_dash)) / cnt, ans)
print(ans) | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | if True:
n, k, m = tuple(map(int, input().split()))
a = list(map(int, input().split()))
else:
n, k, m = 1000, 2, 40
a = list(range(n))
a.sort(reverse=True)
middle_power = sum(a)
num = n
for i in range(n - 1, 0, -1):
if (middle_power - a[i] + min(m - 1, k * (num - 1))) / (num - 1) > (
middle_power + min(m, k * num)
) / num:
middle_power -= a[i]
m -= 1
num -= 1
else:
break
if m == 0:
break
print((middle_power + min(m, k * num)) / num) | IF NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
add = list(0 for _ in range(n))
a.sort()
sm = int(sum(_ for _ in a))
res = 0
for i in range(min(m, n - 1)):
res = max(res, (sm + min((n - i) * k, m - i)) / (n - i))
if i < m:
res = max(res, (sm - a[i]) / (n - (i + 1)))
sm -= a[i]
if n <= m:
res = max(res, a[n - 1] + min(k, m - n + 1))
print(res) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | from itertools import accumulate
n, k, m = [int(x) for x in input().split(" ")]
a = sorted([int(x) for x in input().split(" ")])
a_sum = sum(a)
pref_a = [0] + list(accumulate(a))
def score(rem):
total = len(a) - rem
return (a_sum - pref_a[rem] + min(total * k, m - rem)) / total
print(max(map(score, range(min(m + 1, len(a)))))) | ASSIGN VAR 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 FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
total = sum(a)
best = (total + min(n * k, m)) / n
for i in range(n - 1):
m -= 1
if m < 0:
break
rem = n - i - 1
total -= a[i]
val = (total + min(rem * k, m)) / rem
best = max(best, val)
print(best) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
l = n
m2 = m
maxi = round((s + min(k * l, m2)) / l, 9)
if n - 1 >= m:
n = m + 1
for i in range(n - 1):
s -= a[i]
l -= 1
m2 -= 1
maxi = round(max(maxi, (s + min(k * l, m2)) / l), 9)
print(maxi) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | import sys
n, k, m = [int(tmp) for tmp in sys.stdin.readline().split()]
a = [int(tmp) for tmp in sys.stdin.readline().split()]
a.sort(reverse=True)
sa = sum(a)
sar = sa
ld = n - min([n, m + 1])
rd = n
while rd - ld != 1:
td = (ld + 1 + rd) // 2
avsidthau = (sar - sum(a[td:rd]) + min([m - (n - td), td * k])) / td
avsiuth = (sar + min([rd * k, m - (n - rd)])) / rd
if avsidthau > avsiuth:
sar -= sum(a[td:rd])
rd = td
else:
ld = td
sar += min([m - (n - rd), rd * k])
avs = sar / rd
print(avs) | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR LIST BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR LIST BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR IF VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR LIST BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
a = sorted([int(x) for x in input().split()])
prefix_sum = [sum(a)]
for i in range(n):
prefix_sum.append(prefix_sum[-1] - a[i])
ans = (sum(a) + min(m, n * k)) / n
for i in range(1, min(m, n - 1) + 1):
a = (prefix_sum[i] + min(m - i, k * (n - i))) / (n - i)
ans = max(ans, a)
print(ans) | ASSIGN VAR 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 ASSIGN VAR LIST FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, m, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
s = [] + a
if m * n < k:
s = a[: max(1, n - k + m * n)]
s1 = (sum(s) + min(m * len(s), k)) / len(s)
if k >= n - 1:
ind = n - 1 - a[::-1].index(max(a))
l = a[: max(n - k, ind + 1)]
sd = min(m * len(l), k - (n - len(l)))
l1 = a[0]
k -= n - 1
l1 += min(k, m)
print(max(s1, l1, (sum(l) + sd) / len(l)))
else:
ind = n - 1 - a[::-1].index(max(a))
l = a[: max(n - k, ind + 1)]
sd = k - (n - len(l))
l1 = a[: n - k]
s2 = sum(l1) / (n - k)
print(max(s1, s2, (sum(l) + sd) / len(l))) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST VAR IF BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
array = list(map(int, input().split()))
array.sort()
array = [0] + array
sr = sum(array) / n
sr_max = sr
sr_max += min(m / n, k)
l = n
for i in range(1, min(n, m + 1)):
sr = (sr * l - array[i]) / (l - 1)
sr_max = max(sr + min((m - i) / (l - 1), k), sr_max)
l -= 1
print(sr_max) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Every superhero has been given a power value by the Felicity Committee. The avengers crew wants to maximize the average power of the superheroes in their team by performing certain operations.
Initially, there are $n$ superheroes in avengers team having powers $a_1, a_2, \ldots, a_n$, respectively. In one operation, they can remove one superhero from their team (if there are at least two) or they can increase the power of a superhero by $1$. They can do at most $m$ operations. Also, on a particular superhero at most $k$ operations can be done.
Can you help the avengers team to maximize the average power of their crew?
-----Input-----
The first line contains three integers $n$, $k$ and $m$ ($1 \le n \le 10^{5}$, $1 \le k \le 10^{5}$, $1 \le m \le 10^{7}$) — the number of superheroes, the maximum number of times you can increase power of a particular superhero, and the total maximum number of operations.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{6}$) — the initial powers of the superheroes in the cast of avengers.
-----Output-----
Output a single number — the maximum final average power.
Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.
Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.
-----Examples-----
Input
2 4 6
4 7
Output
11.00000000000000000000
Input
4 2 6
1 3 2 3
Output
5.00000000000000000000
-----Note-----
In the first example, the maximum average is obtained by deleting the first element and increasing the second element four times.
In the second sample, one of the ways to achieve maximum average is to delete the first and the third element and increase the second and the fourth elements by $2$ each. | n, k, m = map(int, input().split())
d = min(n * k, m)
q = list(map(int, input().split()))[:n]
a = [0]
a = a + q
a.sort()
ans = 0
x = sum(a)
for i in range(min(m, n - 1) + 1):
x -= a[i]
v = x + min(m - i, k * (n - i))
ans = max(ans, v / (n - i))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | def answer(n):
if n == 1:
return -1
else:
return [n, n + 1, n * (n + 1)]
n = int(input())
x = answer(n)
if x == -1:
print(x)
else:
print(*x) | FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN LIST VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | from sys import stdin, stdout
n = int(stdin.readline())
ans = []
if n != 1:
for x in range(n, n + 1000):
if ans:
break
for y in range(x + 1, x + 1000):
z = x * y * n // (x * y * 2 - n * (x + y))
if not x * y * n % (x * y * 2 - n * (x + y)) and z != x and z != y:
ans = [x, y, x * y * n // (x * y * 2 - n * (x + y))]
x, y, z = ans
if ans:
print(x, y, z)
else:
print("-1") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
if n == 1:
print(-1)
else:
x = n
y = n + 1
z = x * y
if z > int(1000000000.0):
print(-1)
else:
print(f"{x} {y} {z}") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR STRING VAR STRING VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
a = n
b = n + 1
c = n * (n + 1)
if 2 * a * b * c == n * (a * b + a * c + b * c) and a != b and b != c and a != c:
print(n, n + 1, n * (n + 1))
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
d = 1000000000.0
x = n
y = n + 1
z = n * (n + 1)
if x > d or y > d or z > d or n == 1:
print("-1")
else:
print(x, y, z) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
if n == 1:
print(-1)
elif n == 2:
print(2, 3, 6)
else:
for i in range(1, n + 1):
if n % i == 0:
print(n, n + 1, n * n + n)
exit() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
if n * (n + 1) == n or n * (n + 1) == n + 1:
print("-1")
else:
print(n, n + 1, n * (n + 1)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | primes = [True] * 10001
primes[0] = primes[1] = False
for i in range(2, int(10000**0.5) + 1):
if primes[i]:
for x in range(i * 2, 10001, i):
primes[x] = False
def facto(n):
i = 1
arr = [0] * (n + 1)
while i <= int(n**0.5):
i += 1
if n % i == 0:
while n % i == 0:
n //= i
arr[i] += 1
if n > 1:
arr[n] += 1
return arr
n = int(input())
if primes[n] or n == 1:
if (n + 1) * n != n + 1:
print(n, (n + 1) * n, n + 1)
else:
print(-1)
else:
arr = facto(n)
first2 = 1
cnt = 0
for x in range(2, n + 1):
while cnt < 2 and arr[x]:
arr[x] -= 1
cnt += 1
first2 *= x
if cnt == 2:
break
print(n, n * (first2 + 1), n // first2 * (first2 + 1)) | ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP NUMBER NUMBER NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER WHILE VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
if n == 1:
print(-1)
exit()
x = n
y = n + 1
z = n * (n + 1)
print(x, y, z) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
if n == 1 or n * (n + 1) > 10**9:
print(-1)
else:
print(n, n + 1, n * (n + 1), sep=" ") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER STRING |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
if n == 1:
print("-1")
exit()
else:
b = n + 1
c = b * n
if max(n, b, c) >= 10**9:
print("-1")
else:
print(n, b, c) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | def solve():
n = int(input())
fixed = n
current = n + 1
product = n * current
if n == 1:
print(-1)
return
while True:
while product // n != product // current + 1:
current += 1
product = n * current
if product < 10**9 and current < 10**9 and fixed < 10**9:
print("{} {} {}".format(n, current, product))
return
elif fixed >= 10**9:
print(-1)
elif product > 10**9:
fixed += 1
current = fixed + 1
solve() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN WHILE NUMBER WHILE BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR VAR VAR RETURN IF VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | x = int(input())
s = set()
s.add(x)
s.add(x + 1)
s.add(x * (x + 1))
if len(s) != 3:
print(-1)
else:
print(*list(s)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | def ratios(n):
if n * (n + 1) <= 1000000000 and n != 1:
return n, n + 1, n * (n + 1)
return [-1]
print(*ratios(int(input()))) | FUNC_DEF IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER RETURN LIST NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | def solveQ1(n, a, b, s):
if s[a - 1] == s[b - 1]:
return 0
c = s[b - 1]
n = len(s)
min_dist = n
for i in range(n):
if s[i] == c:
min_dist = min(abs(a - 1 - i), min_dist)
return min_dist
def solveQ2(n, k):
if n == 1:
return 1
if k == pow(2, n - 1):
return n
if k > pow(2, n - 1):
return solveQ2(n - 1, k - pow(2, n - 1))
else:
return solveQ2(n - 1, k)
n = int(input())
def solveQ3(n):
if n == 1:
print(-1)
return
else:
print("{0} {1} {2}".format(n, n + 1, n * (n + 1)))
return
solveQ3(n) | FUNC_DEF IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER RETURN VAR IF VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN EXPR FUNC_CALL VAR FUNC_CALL STRING VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER RETURN EXPR FUNC_CALL VAR VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
x = n
y = n + 1
z = n * (n + 1)
if n < 2 or z > 10**9:
print(-1)
else:
print(x, y, z) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | def yolo(n):
denom = 0
k = 0
if n % 2 == 1:
k = (n + 1) / 2
denom = n * k
if denom > 0:
a, b, c = [int(x) for x in [k, denom + 1, denom * (denom + 1)]]
if (
a == k
and b == denom + 1
and c == denom * (denom + 1)
and (a < 10**9 and b < 10**9 and c < 10**9)
and not duplicates([a, b, c])
):
print(str(a) + " " + str(b) + " " + str(c))
return
k = n
denom = n
a, b, c = [int(x) for x in [k, denom + 1, denom * (denom + 1)]]
if (
a == k
and b == denom + 1
and c == denom * (denom + 1)
and (a < 10**9 and b < 10**9 and c < 10**9)
and not duplicates([a, b, c])
):
print(str(a) + " " + str(b) + " " + str(c))
return
print(-1)
def duplicates(arr):
for i in range(len(arr)):
for x in range(i + 1, len(arr)):
if arr[i] == arr[x]:
return True
return False
yolo(int(input())) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR LIST VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR RETURN ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR LIST VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER VAR BIN_OP NUMBER NUMBER FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
if n == 1:
print(-1)
else:
s = str(n) + " " + str(n + 1) + " " + str(n * (n + 1))
print(s) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR BIN_OP VAR NUMBER STRING FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
a = 2 * (n + 1) - 1
b = n * (n + 1)
c = a // 2
d = (a + 1) // 2
inf = 1000000000.0
if b % c == 0 and b % d == 0:
c = b // c
d = b // d
if b <= inf and c <= inf and d <= inf and b != c and d != c:
print(b, c, d)
else:
print(-1)
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
if n * (n + 1) <= 10**9:
if n == 1:
print(-1)
else:
print(n, n + 1, n * (n + 1))
else:
print(-1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
if n * (n + 1) > 2000000000 or n == 0 or n == 1:
print(-1)
else:
print(n, end=" ")
print(n + 1, end=" ")
print(n * (n + 1), end=" ") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER STRING |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
a, b, c = n, n + 1, n * (n + 1)
if a > int(1000000000.0) or b > int(1000000000.0) or c > int(1000000000.0):
print(-1)
elif a == b or b == c or a == c:
print(-1)
else:
print(a, b, c) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | a = int(input())
b = 1
if a == 3:
b = 0
print("2 7 42")
if a == 1:
print("-1")
b = 0
if b == 1:
print(a, a + 1, a * (a + 1)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | from sys import argv, exit
def get_str():
return input()
def get_int():
return int(input())
def get_ints():
return [int(i) for i in input().split(" ")]
def prnt(*args):
if "-v" in argv:
print(*args)
n = get_int()
if n == 1:
print("-1")
exit(0)
print("{} {} {}".format(n, n + 1, n * (n + 1))) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF IF STRING VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER |
Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction <image> as a sum of three distinct positive fractions in form <image>.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that <image>. Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Examples
Input
3
Output
2 7 42
Input
7
Output
7 8 56 | n = int(input())
a, b, c = n, n + 1, n * (n + 1)
if a == b or b == c or c == a:
print(-1)
else:
print(a, b, c) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR |
The year of 2012 is coming...
According to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes have already gathered on the top of a mountain Arreat to protect us mere mortals from the effect of this terrible evil.
The seven great heroes are: amazon Anka, barbarian Chapay, sorceress Cleo, druid Troll, necromancer Dracul, paladin Snowy and a professional hit girl Hexadecimal. Heroes already know how much experience will be given for each of the three megabosses: a for Mephisto, b for Diablo and c for Baal.
Here's the problem: heroes are as much as seven and megabosses are only three! Then our heroes decided to split into three teams, where each team will go to destroy their own megaboss. Each team member will receive a <image> of experience, rounded down, where x will be the amount of experience for the killed megaboss and y — the number of people in the team.
Heroes do not want to hurt each other's feelings, so they want to split into teams so that the difference between the hero who received the maximum number of experience and the hero who received the minimum number of experience were minimal. Since there can be several divisions into teams, then you need to find the one in which the total amount of liking in teams were maximum.
It is known that some heroes like others. But if hero p likes hero q, this does not mean that the hero q likes hero p. No hero likes himself.
The total amount of liking in teams is the amount of ordered pairs (p, q), such that heroes p and q are in the same group, and hero p likes hero q (but it is not important if hero q likes hero p). In case of heroes p and q likes each other and they are in the same group, this pair should be counted twice, as (p, q) and (q, p).
A team can consist even of a single hero, but it is important that every megaboss was destroyed. All heroes must be involved in the campaign against evil. None of the heroes can be in more than one team.
It is guaranteed that every hero is able to destroy any megaboss alone.
Input
The first line contains a single non-negative integer n (0 ≤ n ≤ 42) — amount of liking between the heroes. Next n lines describe liking in the form "p likes q", meaning that the hero p likes the hero q (p ≠ q). Every liking is described in the input exactly once, no hero likes himself.
In the last line are given three integers a, b and c (1 ≤ a, b, c ≤ 2·109), separated by spaces: the experience for Mephisto, the experience for Diablo and experience for Baal.
In all the pretests, except for examples from the statement, the following condition is satisfied: a = b = c.
Output
Print two integers — the minimal difference in the experience between two heroes who will receive the maximum and minimum number of experience points, and the maximal total amount of liking in teams (the number of friendships between heroes that end up in one team).
When calculating the second answer, the team division should satisfy the difference-minimizing contraint. I.e. primary you should minimize the difference in the experience and secondary you should maximize the total amount of liking.
Examples
Input
3
Troll likes Dracul
Dracul likes Anka
Snowy likes Hexadecimal
210 200 180
Output
30 3
Input
2
Anka likes Chapay
Chapay likes Anka
10000 50 50
Output
1950 2
Note
A note to first example: it the first team should be Dracul, Troll and Anka, in the second one Hexadecimal and Snowy, and in the third Cleo и Chapay. | import itertools
def sets(heros, min_elem, max_elem):
ans = []
if max_elem > len(heros):
max_elem = len(heros)
if min_elem > len(heros):
return []
for i in range(min_elem, max_elem + 1):
s = itertools.combinations(heros, i)
for ss in s:
ans.append(ss)
return ans
def update(set1, set2, set3, x, y, a, b, c, pairs):
q = a // len(set1)
w = b // len(set2)
e = c // len(set3)
m = max(abs(q - w), abs(w - e), abs(e - q))
if m == x:
x = m
y1 = 0
for p in pairs:
if (
p[0] in set1
and p[1] in set1
or p[0] in set2
and p[1] in set2
or p[0] in set3
and p[1] in set3
):
y1 += 1
if y < y1:
y = y1
if m < x:
x = m
y = 0
for p in pairs:
if (
p[0] in set1
and p[1] in set1
or p[0] in set2
and p[1] in set2
or p[0] in set3
and p[1] in set3
):
y += 1
return x, y
def solve(n, pairs, a, b, c):
x, y = 100000000000000, 0
heros = ["Anka", "Chapay", "Cleo", "Troll", "Dracul", "Snowy", "Hexadecimal"]
for_set1 = sets(heros, 1, 5)
for set1 in for_set1:
heros2 = []
for i in heros:
if i not in set1:
heros2.append(i)
for_set2 = sets(heros2, 1, 7 - len(set1))
for set2 in for_set2:
set3 = []
for i in heros2:
if i not in set2:
set3.append(i)
if len(set1) > 0 and len(set2) > 0 and len(set3) > 0:
x, y = update(set1, set2, set3, x, y, a, b, c, pairs)
return x, y
n = int(input())
pairs = []
for i in range(n):
x, _, y = input().split()
pairs.append((x, y))
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
x, y = solve(a, pairs, a, b, c)
print(x, y) | IMPORT FUNC_DEF ASSIGN VAR LIST IF VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR RETURN LIST FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER RETURN VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.