Problem:


Score : 300 points

Problem Statement

You have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \leq i \leq N) is v_i.

When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot.

After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.

Constraints

2 \leq N \leq 50

1 \leq v_i \leq 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
v_1 v_2 \ldots v_N

Output

Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.

Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.

Sample Input 1

2
3 4

Sample Output 1

3.5

If you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.

Printing 3.50001, 3.49999, and so on will also be accepted.

Sample Input 2

3
500 300 200

Sample Output 2

375

You start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:

Use the ingredients of values 500 and 300 to produce an ingredient of value (500 + 300) / 2 = 400. The next composition will use this ingredient and the ingredient of value 200, resulting in an ingredient of value (400 + 200) / 2 = 300.

Use the ingredients of values 500 and 200 to produce an ingredient of value (500 + 200) / 2 = 350. The next composition will use this ingredient and the ingredient of value 300, resulting in an ingredient of value (350 + 300) / 2 = 325.

Use the ingredients of values 300 and 200 to produce an ingredient of value (300 + 200) / 2 = 250. The next composition will use this ingredient and the ingredient of value 500, resulting in an ingredient of value (250 + 500) / 2 = 375.

Thus, the maximum possible value of the last ingredient remaining is 375.

Printing 375.0 and so on will also be accepted.

Sample Input 3

5
138 138 138 138 138

Sample Output 3

138



Sample input:
2
3 4


Sample output:
3.5

Submission status: Wrong Answer

Solution code:
import re

n = int(input())
v = sorted(list(map(int, input().split())))

ans = (v[0]+v[1])/2

def del0(x):

    x = str(x)

    if re.search(r'\.0.+', x):
        return x
    
    elif re.search(r'\.0', x):
        x = x.replace(r'.0', '')
        return x
    else:
        return x

if n == 2:
    ans = ans
    print(del0(ans))

elif n > 2 and n % 2 == 0:
    for i in range(int(n/2)):
        ans = (ans + v[i+2])/2
    print(del0(ans))

elif n % 2 != 0:
    for i in range(n-2):
        ans = (ans + v[i+2])/2
    print(del0(ans))

Submission status: Wrong Answer

Solution code:
import re

n = int(input())
v = sorted(list(map(int, input().split())))

ans = (v[0]+v[1])/2

def del0(x):

    x = str(x)

    if re.search(r'.0', x):
        x = x.replace(r'.0', '')
        return x
    
    else:
        return x

if n == 2:
    ans = ans
    print(del0(ans))

elif n > 2 and n % 2 == 0:
    for i in range(int(n/2)):
        ans = (ans + v[i+2])/2
    print(del0(ans))

elif n % 2 != 0:
    for i in range(n-2):
        ans = (ans + v[i+2])/2
    print(del0(ans))

Submission status: Wrong Answer

Solution code:
import re

n = int(input())
v = sorted(list(map(int, input().split())))

ans = (v[0]+v[1])/2

if n == 2:
    ans = ans

elif n > 2 and n % 2 == 0:
    for i in range(int(n/2)):
        ans = (ans + v[i+2])/2

else:
    for i in range(n-2):
        ans = (ans + v[i+2])/2

if re.search('.0', str(ans)):
    ans = str(ans).replace('.0', '')
    print(ans)

else:
    print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial as fact
import math
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
from collections import deque

#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

def combinations(n,r):
	return list(itertools.combinations(range(n),r))



def all_sets(num_list):
	subsets=[]
	for i in range(2,len(num_list) + 1):
		for c in combinations(num_list, i):
			subsets.append(c) 
	return subsets

#公約数の列挙
def ch(x1):
	cf=[]
	for i in range(2,math.sqrt(x1)+1):
		if x1 % i==0:
			cf.append(i)
	return cf

def CountOneRoots(x,y):
	#x:縦，y:横
	return fact(x+y)/fact(x)/fact(y)

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
			


n=input1()
v=input_array()
v.sort(reverse=True)

b_value=0
for i in range(n-1):
	b_value=(v.pop()+v.pop())/2
	v=[b_value]+v
print(v[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int, input().split()))

C = sorted(V)
print(C)
ans = 0

a = C[0]
for i in range(1, N):
    a = (a + C[i]) / 2
ans = max(ans, a)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = sorted(map(int,input().split()))

value = v[0]
for i in range(1,n):
    value = (value + v[i]) / 2
print(int(value))

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
for i in range(1,n):
    ls[0] = (ls[0]+ls[i])/2
print(int(ls[0]))

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = list(map(int,input().split()))
ls.sort()
for i in range(1,n):
    ls[0] = (ls[0]+ls[i])/2
    print(ls)
print(int(ls[0]))

Submission status: Wrong Answer

Solution code:
N=int(input())
V=sorted(list(map(int, input().split())), reverse=True)

result=V[0]
for i in range(1,N):
  result =(result + V[i])/2
print(result)

Submission status: Wrong Answer

Solution code:
N=int(input())
V=sorted(list(map(int, input().split())), reverse=True)
if len(set(V))==1:
  print(V[0])
else:
  while True:
    v1=V.pop(0)
    v2=V.pop(0)
    v3=(v1+v2)/2
    V.append(v3)
    V=sorted(V, reverse=True)
    if len(V)==1:
      break
  print(V[0])

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
v = LIST()
v.sort()
ans = v[0]

for x in range(1, N):
	ans = (ans+x)/2
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
n = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
    print(v[0])
elif len(set(v)) == 2:
   print(sum(list(set(v)))/2)
else:
    p = set(v)
    res = []
    s = list(combinations(p, 2))
    for i in s:
        a = sum(i)/2
        b = max(list(p-set(i)))
        res.append((a+b)/2)
    print(max(res))

Submission status: Wrong Answer

Solution code:
N=int(input())
v=sorted(list(map(int,input().split())))
for i in range(N-1):
  v[i+1]=(v[i]+v[i+1])/2

print(int(v[N-1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
while len(A)>=2: 
    X = (A[0]+A[1])/2
    A.pop(0)
    A.pop(0)
    A.append(X)
    A.sort()
else:
    print(*(A))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
while len(A)>=2: 
    X = float((A[0]+A[1])/2)
    A.pop(0)
    A.pop(0)
    A.append(X)
    A.sort()
else:
    print(*A)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
while len(A)>=2: 
    X = int((A[0]+A[1])/2)
    A.pop(0)
    A.pop(0)
    A.append(X)
    A.sort()
else:
    print(*A)

Submission status: Wrong Answer

Solution code:
N=int(input())
V=sorted(list(map(int,input().split())))
print(V)
while len(V)!=2:
    a=(V[0]+V[1])/2
    V.pop(0)
    V.pop(1)
    V.insert(0,a)
print((V[0]+V[1])/2)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
v.sort()
ans = v[0]
for i in range(1,n):
    ans = round((ans + v[i])/2,1)
print(ans)

Submission status: Wrong Answer

Solution code:

n=int(input())
ans=0
v=list(map(int,input().split()))
v.sort()

if n>2:
    for i in range(2,n):
        ans=(v[0]+v[1])*(2**(-n+1))+v[i]*(2**(-n+i))
else:
    ans=(v[0]+v[1])*(2**(-n+1))

if ans-int(ans)==0:
    print(int(ans))
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
h = list(map(int,input().split(" ")))

plsl = []
plsn = 0
for i in range(n-1):
    if h[i]>= h[i+1] and i == n-2:
        plsn += 1
        # print(plsn)
        plsl.append(plsn)
        # print(plsl)
    elif h[i]>= h[i+1] and i < n-2:
        plsn += 1
        # print(plsn)
    else:
        plsl.append(plsn)
        # print(plsl)
        plsn = 0
        # print(plsn)
plsl.sort(reverse = True)
print(plsl[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
v.sort(reverse=False)
#print(v)
ave = (v[0]+v[1])/2

for i in range(1,n-1):
    #print(ave)
    ave = (ave+v[i+1])//2
    #print(ave)
print(ave)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
Asum1 = sum(A)
Asum2 = sum(A)-A[N-1]
J = N%2
B = N

if J == 0:
    for _ in range(N//2):
        Asum1 /= 2
    print(Asum1)
else:
    for _ in range((N-1)//2):
        Asum2 /= 2
    Asum2 = (Asum2+A[N-1])/2
    print(Asum2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
Asum = sum(A)
J = N%2
B = N

if J == 0:
    B -= 1
    print(Asum/2**B)
elif Asum == A[0]*N:
    print(A[0])
else:
    B -= 3
    print((((Asum-A[N-1])/(2**B))+A[N-1])/2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
Asum = sum(A)
J = N%2
B = N

if J == 0:
    B -= 1
    print(Asum/2**B)
elif Asum == A[0]*N:
    print(A[0])
else:
    B -= 2
    print((((Asum-A[N-1])/(2**B))+A[N-1])/2)

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int,input().split()))

V.sort()
ans = 0.

if N == 2:
  ans = sum(V) / 2.
  print(ans)
  exit()
  
for i in range(N):
  if i == 0:
    ans += V[i] / 2.
  else:
    ans += V[i] / pow(2,N-i)
    
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
N = int(input())
v = list(map(int, input().split()))
v.sort()
ans = deque()

while len(v) > 1:
    odd = []
    if len(v) % 2 == 1:
        odd.append(v[len(v) - 1])

    for i in range(1, len(v), 2):
        ans.append((v[i - 1] + v[i]) / 2)

    if len(odd) == 1:
        ans.append(odd[0])
    v = ans
    ans = deque()

print(v[0])

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
v = list(map(int, input().split()))

v.sort(reverse=True)

while len(v) > 1:
    v.append((v.pop() + v.pop())/2)

print(v)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
v = list(map(int, input().split()))

v.sort()

while len(v) > 1:
    a = []
    for i in range(math.ceil(len(v)/2)):
        try:
            a.append((v[i*2]+v[i*2+1])/2)
        except IndexError:
            a.append(v[-1])

    v = a

print(a[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
B = (A[0] + A[1]) / 2
for i in range(N-2):
    B = (B + A[i+2]) / 2
print(int(B))

Submission status: Wrong Answer

Solution code:
n = int(input())
v  = list(map(int, input().split()))
#h, w = list(map(int, input().split()))
v.sort()
ans = 0
point = (v[0]+v[1])/2
if n == 2:
    print(point)
else:
    for i in range(2, n):
        point = (point+v[i])/2

print(point)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = sorted(list(map(int, input().split())))
for i in range(N-1):
    a = (v[i]+v[i+1])/2
    v[i+1] = int(a)
    v[i] = 'A'
    a = 0
print(v[-1])

Submission status: Wrong Answer

Solution code:
N=int(input())
v=list(map(int,input().split()))
for i in range(N-1):
  v.sort()
  V=(v[0]+v[1])/2
  del v[0:2]
  v.append(V)
  print("v",v)
print(v)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))

v.sort()
ans = (v[0] + v[1]) / 2

for i in range(2, n):
    print(i)
    ans = (ans + v[i]) / 2
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=sorted(map(int,input().split()))
ans=0
for i in range(n-1):
    ans += (v[i]+v[i+1])/2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int, input().split()))

v.sort()

for i in range(len(v)):
    if i==0:
        continue

    a = v.pop(1)
    b = v.pop(0)
    v.append((a+b)/2)


print(v[0])

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
M = np.fromiter(input().split(), dtype=int)
K = (0.5) ** np.arange(1, N+1)
K[-1] = K[-2]
print(np.dot(M, K))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
M = np.fromiter(input().split(), dtype=int)
K = (0.5) ** np.arange(1, N+1)
print(np.dot(M, K))

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
v.sort()

while n != 1:
  sign = n%2
  temp = []
  
  if sign == 0:
    for i in range(n//2):
      temp.append((v[2*i]+v[2*i+1])/2)
      
  elif sign == 1:
    for i in range((n-1)//2):
      temp.append((v[2*i]+v[2*i+1])/2)
      
    temp.append(v[n-1])
    
  n = len(temp)
  v = temp
  
print(v[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
lst=list(map(int, input().split()))

'''
lst=sorted(lst, reverse=True)
new=[lst[i]*(1/2)**(i+1) for i in range(n-1)]
print(sum(new)+lst[-1]*(1/2)**(n-1))
'''
total=0
for i in range(n-1):
    total+=lst[i]*(1/2)**(i+1)
print(total+lst[-1]*(1/2)**(n-1))

Submission status: Wrong Answer

Solution code:
n = int(input()) #具罪数
v = list(map(int,(input().split()))) #価値
sum_now = 0
sum_old = 0
v.sort()
print(v)

tmp = v[0]
for i in range(1,n):
    tmp = ((tmp + v[i])  /2) # 2n -1 回2で割る
print(tmp)

Submission status: Wrong Answer

Solution code:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.buffer.readline().rstrip())
    V = list(map(int, sys.stdin.buffer.readline().split()))
    V.sort(reverse=True)

    ret = 0
    for n in range(N-1):
        if ret == 0:
            ret = (V[n] + V[n+1]) / 2
        else:
            ret = (ret + V[n+1]) / 2
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.buffer.readline().rstrip())
    V = list(map(int, sys.stdin.buffer.readline().split()))
    V.sort(reverse=True)

    ret = 0
    for n in range(N-1):
        ret = (V[n] + V[n+1]) / 2

    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.buffer.readline().rstrip())
    V = list(map(int, sys.stdin.buffer.readline().split()))
    V.sort()

    ret = 0
    for n in range(N-1):
        ret = (V[n] + V[n+1]) / 2

    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
v.sort()
asa = 0
for i in range(1,n):
     v[n-i-1] = (v[n-i-1] + v[n-i])/2
print(v[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
asa = 0
for i in range(1,n):
     v[n-i-1] = (v[n-i-1] + v[n-i])/2
print(v[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int, input().split()))

V = sorted(V)

ans = 0.0

for v in V:
  ans += v
  ans /=2.0
  
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = [int(e) for e in input().split()]

v.sort #昇順に並べる
result = v[0]
for i in range(1, N):
    result = (result + v[i]) / 2
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
vlist = sorted(list(map(int, input().split())))[::-1]
for _ in range(N-1):
    vlist.insert(0, (vlist.pop(0)+vlist.pop(0))/2)
print(vlist[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int, input().split()))
V.sort()
x = V[0]
for i in range(N-1):
    x += V[i]
    x /= 2
print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int, input().split()))
V.sort()
x = V[0]
for i in range(N-1):
    x += V[1]
    x /= 2
print(x)

Submission status: Wrong Answer

Solution code:

N = int(input())

A = list(map(int,input().split()))
A = sorted(A)
ans = 0
for i in range(N):
    if i == 0:
        ans += (A[i]+A[i+1])/2
        print(ans)
    elif i<N-1:
        ans = (ans+A[i+1])/2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(float,input().split()))
v.sort()
for i in range(0,100,2):
  v.append((v[i]+v[i+1])/2)
  v[i] = v[i+1] = 0
  v.sort()
  print(v)
  if v[-2] == 0:
    break
print(v[-1])

Submission status: Wrong Answer

Solution code:

def submit():
    n = int(input())
    vlist = list(map(int, input().split()))
    
    # mergeを貪欲に行う
    curr_n = n
    while curr_n > 1:
        merge_indice = (0, 0)
        min_diff = float('inf')
        for i in range(curr_n):
            for j in range(i + 1, curr_n):
                # 平均した際にできるだけ価値が減らないペアを選ぶ
                diff = max(vlist[i], vlist[j]) - min(vlist[i], vlist[j])
                if min_diff > diff:
                    min_diff = diff
                    merge_indice = (i, j)
                    
        avg = (vlist[merge_indice[0]] + vlist[merge_indice[1]]) / 2
        vlist.pop(merge_indice[0])
        vlist.pop(merge_indice[1] - 1)
        vlist.append(avg)
        curr_n -= 1

    print(vlist[0])


if __name__ == "__main__":
    submit()

Submission status: Wrong Answer

Solution code:
# C
import heapq # 優先度付きキュー(最小値取り出し)
n = int(input())
v = list(map(int, input().split()))
v = list(map(lambda x: x*(-1), v))  # 各要素を-1倍
heapq.heapify(v)   # ヒープ化
ans = 0
for i in range(n-1):
    tmp1 = heapq.heappop(v)*(-1)        # 最大値の取り出し
    tmp2 = heapq.heappop(v)*(-1)        # 最大値の取り出し
    tmp = (tmp1 + tmp2) / 2
    heapq.heappush(v, (-1)*(tmp))
ans = heapq.heappop(v)*(-1)        # 最大値の取り出し
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
V=list(map(int,input().split()))
V=sorted(V)
ans=V[0]
for i in range(1,N-1):
  ans=(ans+V[i])/2
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input()) 
lst=list(map(int,input().split())) 
#print(lst) 
a=[] 

for i in range(n): 
	if i==0: 
		#print(lst[i]) 
		a.append(lst[i]) 
	else: 
		#print(lst[i]) 
		a.append((a[-1]+lst[i])/2)   
print(a[-1])

Submission status: Wrong Answer

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	k = 0
	n = len(l)
	l = sorted(l)
	while(k < n-1):
		ans = l[0] + l[1]
		zz = ans/2
		l.pop(0)
		l.pop(0)
		l.append(zz)
		k += 1
	return round(l[0],10)

N = int(stdin.readline())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l)
print("%10f"%ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int,input().split()))
v.sort()
ans = (v[0] + v[1])/2
for i in range(2,N):
  ans = (ans + v[i])/2
print(ans)
print(v)

Submission status: Wrong Answer

Solution code:
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *H = map(int, read().split())
cnt = 1

H.sort()

ans = H[0]
print(H)
for i in H[1:]:
    print(ans, cnt)

    ans += cnt * i
    cnt *= 2
    print(ans, cnt)
print(ans / cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
v=list(map(int,input().split()))
while len(v)>1:
  v=sorted(v)
  v_1=v.pop(0)
  v_2=v.pop(0)
  v.append((v_1+v_2)/2)
print(v)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int,input().split()))
v.sort()

while len(v) >= 2:
    if len(v) % 2 == 0:
        v.sort()
        newv = [(v[i] + v[i+1])/2 for i in range(0,len(v)-1,2)]
        v = newv
    else:
        v.sort()
        f = v[len(v)-1]
        newv = [(v[i] + v[i+1])/2 for i in range(0,len(v)-2,2)]
        v = newv
        v.append(f)

if len(v) == 1:
    print(v[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int,input().split()))
v.sort()

while len(v) >= 2:
    if len(v) % 2 == 0:
        newv = [(v[i] + v[i+1])/2 for i in range(0,len(v)-1,2)]
        v = newv
    else:
        f = v[len(v)-1]        
        newv = [(v[i] + v[i+1])/2 for i in range(0,len(v)-2,2)]
        v = newv
        v.append(f)

if len(v) == 1:
    print(v[0])

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
v = LIST()

print(v)
for i in range(N - 1):
	v = sorted(v)
	mix = (v.pop(0) + v.pop(0))/2
	v.insert(0, mix)
print(v[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
M = list(map(int,input().split()))
X = sorted(M)
print(X)
c = 0
for i, v in enumerate(X):
    if i >= N-1:
        break
    else:
        a = X[i]+X[i+1]
        b = a/2
        X[i+1]= a/2

print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
 
a.sort()
for i in range(n-1):
    a[i+1] = (a[i] + a[i+1] / 2)

print(a[-1])

Submission status: Wrong Answer

Solution code:
def main():
  import sys
  from collections import deque
  n=int(input())
  v=list(map(int,sys.stdin.read().split()))
  w=deque(sorted(v))
  ans=(w.popleft()+w.popleft())/2
  for i in range(n-2):
    ans+=w.popleft()/2
  print(ans)
if __name__=="__main__":
  main()

Submission status: Wrong Answer

Solution code:
N=int(input())
L1=sorted(list(map(int,input().split())))
ans=L1[0]
L1.pop(0)
for i in range(len(L1)):
    ans=(ans+L1[i])/2
    print(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
L1=sorted(list(map(int,input().split())))
ans=L1[0]
L1.pop(0)
for i in range(len(L1)):
    ans=(ans+L1[i])//2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int, input().split())
# N = 3
# a = [200, 300, 500]

s = sorted(a)
t = 0
result = 0
if len(s) == 1:
    result = s[0]
    
for i in range(0, N-1):
    if i == N - (N - 1):
        result = (t + s[i+1]) / 2
    z = (s[i] + s[i+1]) / 2
    t = z
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = map(int, input().split())
# N = 3
# a = [200, 300, 500]

s = sorted(a)
t = 0
result = 0
for i in range(0, N-1):
    if i == N - (N - 1):
        result = (t + s[i+1]) / 2
    z = (s[i] + s[i+1]) / 2
    t = z
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int, input().split()))
v.sort()
if N == 2:
  print((v[0] + v[1]) / 2)
else:
  s = (v[0]+v[1])/2
  for i in range(3, N):
    s = (s + v[i])/2
  print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
vlist = sorted(list(map(int, input().split())))[::-1]
for i in range(N - 1):
    a = vlist.pop(0)
    vlist[0] = (vlist[0] + a) / 2
print(vlist[-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
vl = list(map(int, input().split()))
vl_s = sorted(vl)
print(vl_s)

n1 = vl_s[0]
for i in range(1, n):
    n2 = vl_s[i]
    ave = (n1 + n2) / 2
    n1 = ave

print(ave)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = [int(_) for _ in input().split()]

vs = sorted(v)
sm = 0
for i in range(n-1):
    sm += (0.5**(i+1))*v[i]
ans = int(sm + (0.5**(n-1))*v[n-1])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = list(map(int,input().split(" ")))
lst.sort()
print(lst)
val = min(lst)
for i in range(1,len(lst)):
  print("i=%d" %i)
  val += (2**(i-1))*lst[i]
  print(val)
print(val/(2**(N-1)))

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
sort_v = sorted(v)
ans = sort_v[0]
for i in range(1, n):
  ans += (2**(i-1)) * sort_v[i]
ans /= 2**(n-1) 
print((v[0]+v[1])/2)

Submission status: Wrong Answer

Solution code:
# 

n = int(input())
l = [int(x) for x in input().split()]
i =0
while len(l) >= 2:
    l.sort()
    a = l.pop(i)
    b = l.pop(i)
    c = (a + b) / 2
    l.append (c)

print(l)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))

v_s = sorted(v)

for i in range(len(v_s)-1):
    v_s[i+1] = (v_s[i] + v_s[i+1]) / 2
    v_s[i] = 0

sum(v_s)

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
a.sort()
tmp=(a[0]+a[1])/2
for i in range(2,n):
  tmp=(tmp+a[i])/2
print(int(tmp))

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
for i in range(n-1):
  a.sort()
  _min=a[-1]
  jj,kk=0,0
  for j,k in zip(a,a[1:]):
    if _min>min(_min,k-j):
      _min=min(_min,k-j)
      jj,kk=j,k  
  a.remove(jj)
  a.remove(kk)
  a.append((jj+kk)/2)
print(int(a[0]))

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
for i in range(n-1):
  a.sort()
  b=(a[0]+a[1])/2
  a[:2]=[b]
print(int(a[0]))

Submission status: Wrong Answer

Solution code:
n = int(input())
L = []
value = 0
L = list(map(int, input().split()))

L2 = sorted(L, reverse=True)
value = (L2[n - 2] + L2[n - 1]) / 2
for j in range(n - 2):
    value = (L2[j] + value) / 2

print(value)

Submission status: Wrong Answer

Solution code:
n,*v=map(int,open(0).read().split())
v.sort()
a=(v[0]+v[1])/2
for i in range(2,n):
  a=(a+v[i])//2
print(a)

Submission status: Wrong Answer

Solution code:
n=int(input())
vlis=list(map(int,input().split()))
while len(vlis)>=2:
	tlis=[]
	for i in range(len(vlis)-1):
		t=(vlis[i]+vlis[i+1])/2
		tlis.append(t)
	vlis.insert(tlis.index(min(tlis)),min(tlis))
	for i in range(2):
		vlis.pop(tlis.index(min(tlis))+1)
		
print(vlis[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
vlis=list(map(int,input().split()))
while len(vlis)>=2:
	tlis=[]
	for i in range(len(vlis)-1):
		t=(vlis[i]+vlis[i+1])/2
		tlis.append(t)
	vlis.insert(tlis.index(min(tlis)),min(tlis))
	for i in range(2):
		vlis.pop(tlis.index(min(tlis))+1)
		
print(int(vlis[0]))

Submission status: Wrong Answer

Solution code:
n=int(input())
v=list(map(int,input().split()))
a=sorted(v)
if n==2:
    ans=(a[0]+a[1])/2
    print(ans)
    exit()
awase=(a[0]+a[1])/2
for i in range(3,n-1):
    awase=(awase+a[i])/2
awase=(awase+a[n-1])/2
print(awase)

Submission status: Wrong Answer

Solution code:
from math import floor


def main():
    N = int(input())
    v = list(map(int, input().split(" ")))
    while len(v) > 1:
        N = len(v)
        v.sort()
        w = []
        if len(v) % 2 == 1:
            w.append(v[-1])
            N -= 1
        for i in range(floor(N / 2)):
            w.append((v[i * 2] + v[i * 2 + 1]) / 2)
        v = w
    print(v[0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
value = list(map(int, input().split(" ")))
value.sort()
value = deque(value)
que = deque()
ans = 0
a = value.popleft()
b = value.popleft()
c = (a+b)/2
que.append(c)
while value:
  a = value.popleft()
  if value:
    b = value.popleft()
    c = que.popleft()
    if b < c:
      que.appendleft(c)
      c = (a+b)/2
      que.append(c)
    elif b > c:
      value.appendleft(b)
      c = (a+c)/2
      que.append(c)
    else:
      que.appendleft(c)
      c = (a+b)/2
      que.append(c)      
  else:
    c = que.popleft()
    c = (a+c)/2
    que.append(c)
ans = que[0]
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
n = int(input())
value = list(map(int, input().split(" ")))
value.sort()
value = deque(value)
que = deque()
ans = 0
a = value.popleft()
b = value.popleft()
c = (a+b)/2
que.append(c)
while value:
  a = value.popleft()
  if value:
    b = value.popleft()
    c = que.popleft()
    if b <= c:
      que.append(c)
      c = (a+b)/2
      que.append(c)
    else:
      value.appendleft(b)
      c = (a+c)/2
      que.append(c)
  else:
    c = que.popleft()
    c = (a+c)/2
    que.append(c)
ans = que[0]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int,input().split()))

def main():
    ans = V[0]
    V.sort()
    for i in range(1,N):
        ans = (ans + V[i]) /2
    print(ans)
    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().split()
a.sort()
ans=int(a[0])
for i in range(n-1):
    ans=(ans+int(a[1]))/2
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
v=list(map(int,input().split()))
list.sort(v)

result=0
for i in range(1,n):
    if i==1:
        result+=(v[i-1]+v[i]/2)
    else:
        result=(result+v[i])/2
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = sorted(list(map(lambda x: int(x), input().split())))
ans = 0
while len(v) != 1:
    a = v.pop(0)
    b = v.pop(0)
    ans = (a + b) / 2
    v.append(ans)
    v = sorted(v)
print(int(v[0]))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
print(a)
i=0
l=len(a)
divider=0.5
s=0
while(i<l-1):
    s+=(a[i]*divider)
    divider*=0.5
    i+=1
s+=a[i]*divider*2
print(s)