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:
n = int(input())
v = list(map(int, input().split()))
sort_v = sorted(v, reverse=False)
print(sort_v)
sum_tmp = 0
for i in range(2, n):
  sum_tmp += sort_v[i]*(2**(i-1))
sum_all = sort_v[0] + sort_v[1] + sum_tmp
div = 2 ** (n-1)
ans = sum_all / div
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    v = sorted(list(map(int, input().split())))
    while len(v) > 2:
        new_v = []
        for j in range(len(v) // 2)[::2]:
            new_v.append(sum(v[j:j + 2]) / 2)
        if len(v) % 2 == 1:
            new_v.append(v[-1])
        v = new_v
    print(sum(v) / 2)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

V.sort()
V_sum = (V[0] + V[1]) / 2

if N != 2:
  for i in range(2, N-1):
    V_sum = (V_sum + V[i]) / 2

print(V_sum)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
v = list(map(int,input().split()))
max_num = max(v)
v.remove(max(v))

if N >2:
	x = min(v)
	v.remove(min(v))
	y = min(v)
	v.remove(min(v))
	value = (x+y)/2
	if len(v) !=0:
		value = (value+min(v))/2
		v.remove(min(v))
	print((value+max_num)/2)
	sys.exit()

else:
	print((max_num+v[0])/2)
	sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
v = list(map(int,input().split()))
max_num = max(v)
v.remove(max(v))

if N >2:
	x = min(v)
	v.remove(min(v))
	y = min(v)
	v.remove(min(v))
	value = (x+y)/2
	print('len:',len(v))
	if len(v) !=0:
		value = (value+min(v))/2
		v.remove(min(v))
	print((value+max_num)/2)
	sys.exit()

else:
	print((max_num+v[0])/2)
	sys.exit()

Submission status: Wrong Answer

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

if n>=3:
    ai=a[-1]
    aii=a[-2]
    aiii=a[-3]
    al=(aii+aiii)/2
    ans=(al+ai)/2

if n==2:
    ans=(a[0]+a[1])/2
if n==1:
    ans=a[0]

print('{:.6f}'.format(ans))

Submission status: Wrong Answer

Solution code:
def find(s):
    k = []
    for i in range(len(s)):
        for j in range(len(s)):
            if(i!=j):
                k.append([abs(s[i]-s[j]),s[i],s[j],(s[i]+s[j])/2])
    #print(k)
    f = min(k)
    l = [i for i in k if i[0]==f[0]]
    f = [-1,-1,-1,-1]
    for i in l:
        if(i[3]>f[3]): f = i
    return f
    
n = int(input())
s = list(map(int,input().split()))
while(len(s)!=1):
    cur = find(s)
    #print(s)
    s = [i for i in s if i!=cur[1] and i!=cur[2]]
    s.append(cur[3])
print(s[0])

Submission status: Wrong Answer

Solution code:
n = int(input())

#1~N
V = list(map(int,input().split()))

V.sort()

a = []

tmp = 0

for v in V:
  if tmp == v:
    continue
  tmp = v
  a.append(v)
  
if len(a) == 1:
  print(a[0])
  exit()
  
#b = []
#cnt = 0
#for i in range(len(a)-1):
#  b.append( (a[i+1] - a[i],cnt) )
#  cnt += 1
  
#sorted(b)
  
#print(b)

#tmp = a[b[0][1]]
l = len(a)

for i in range(l-1):
  b = []
  cnt = 0
  if len(b) == 1:
    break
  for j in range(l-i-1):
    b.append( (a[j+1] - a[j],cnt) )
    cnt += 1
  sorted(b)
#  l2 = len(a)
#  print("a = {}".format(a))
#  print("b[0][1] = {}".format(b[0][1]))
  ans = (a[b[0][1]] + a[b[0][1]+1])/2
  a.pop(b[0][1])
  a.pop(b[0][1])
  a.insert(0,ans)

#ans = a[0]

#for i in range(len(a)-1):
#  ans = (ans + a[i+1])/2
  

print(a[0])

Submission status: Wrong Answer

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

v.sort()
ans = None

a = None
b = None

for i in range(N-1):
    mi = 10000
    for j in range(len(v)-1):
        for k in range(j+1,len(v)):
            if mi >= abs(v[j]-v[k]):
                mi = abs(v[j]-v[k])
                a = j
                b = k
    
    ans = (v[a]+v[b])/2


    del v[a]
    del v[b-1]

    v.append(ans)


    v.sort()

print(ans)

Submission status: Wrong Answer

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

if len(v) == 2:
  ans = (v[0]+v[1])/2
  print(ans)
else:
  x = (sv[0]+sv[1])/2
  print((x + sv[n-1])/2)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = [int(i) for i in input().split()]
if N%2 == 0:
  print(sum(v)/N)
else:
  print(max([((sum(v)-i)/(N-1)+i)/2 for i in v]))

Submission status: Wrong Answer

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

ans = vs[-1]

diffs = []
pre_v = vs[0]
for v in vs[1:]:
    diffs.append(v-pre_v)
    pre_v = v


def f(diffs):


    return diffs

for _ in range(N-2):
    index, m = min(enumerate(diffs), key = lambda x:x[1])

    if index-1 >= 0 :
        diffs[index-1] += m/2
    if index+1 < len(diffs):
        diffs[index+1] += m/2

    del diffs[index]

print(ans-diffs[0]/2)

Submission status: Wrong Answer

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

while len(A)>=3:
  first = (A[0]+A[-1])/2
  A.remove(min(A))
  A.remove(max(A))
  A.append(first)
print((A[0]+A[1])/2)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
# v = sort(v)
if n < 1:
    print(0)
elif n <= 2:
    print(sum(v) / 2)
else:
    for i in range(n):
        vmax = max(v)
        v2 = sorted(v)[-2]
        v3 = sorted(v)[-3]
        vv = (v2 + v3) / 2
    print((vmax + vv) / 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def execute(a_array):
    sum_result = []
    for i in range(len(a_array)):
        if i == len(a_array) - 1:
            break
        result = (a_array[i] + a_array[i+1]) / 2
        sum_result.append((result, i))
    
    sum_result.sort()
    true_result = sum_result[0]
    
    a_array.pop(true_result[1])
    a_array.pop(true_result[1])
    a_array.append(true_result[0])
    
    if len(a_array) == 1:
        print(a_array[0])
    else:
        execute(a_array)

import sys
a = []
for l in sys.stdin:
    a.append(l)

a_array = a[1].split(' ')
execute([float(i) for i in a_array])

Submission status: Wrong Answer

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

v.sort()
sum = (v[0] + v[1])/2
print(v)
if N >= 2:
  for i in range(2,N):
    sum = (sum + v[i])/2


print(sum)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

N = input()
N = int(N)

v = []
v = input().split()
v.sort()

v[0] = int(v[0])

for i in range(N - 1) :
	v[i + 1] = (int(v[i]) + int(v[i + 1])) / 2

print(v[N - 1])

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int,input().split()))
if len(s) == 2:
    print((s[0] + s[1]) / 2)
    exit()
min_ave = 100000
for i, val in enumerate(s):
    for j, val2 in enumerate(s):
        if i == j:
            continue
        ave = (val + val2) / 2
        if min_ave > ave:
            min_ave = ave 
print((max(s) + min_ave)/2)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
v = list(map(int,input().split()))
max_num = max(v)
v.remove(max_num)

if N >2:
	x = min(v)
	v.remove(x)
	y = min(v)
	v.remove(y)
	value = (x+y)/2

	if len(v) !=0:
		value = (value+min(v))/2
		v.remove(min(v))
	print((value+max_num)/2)
	sys.exit()

else:
	print((max_num+v[0])/2)
	sys.exit()

Submission status: Wrong Answer

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

v_sorted = sorted(v)
average = 0

for i in range(N - 1):
    v_sorted[i + 1] = (v_sorted[i] + v_sorted[i + 1]) / 2
    print(v_sorted, average)

print(v_sorted[-1])

Submission status: Wrong Answer

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

SUM = 0
v.sort()
ite = 0
while(ite < N-1):
    SUM = (int(v[ite])+int(v[ite+1]))/2
    v[ite+1] = SUM
    ite += 1

print(SUM)

Submission status: Wrong Answer

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

v.sort()
ans = None

V = []
a = None
b = None
for i in range(1, N):
    V.append(abs(v[i]-v[i-1]))

for i in range(N-1):
    mi = 10000
    for j in range(1,len(v)):
        if mi >= abs(v[j]-v[j-1]):
            mi = abs(v[j]-v[j-1])
            a = j-1
            b = j
    
    ans = (v[a]+v[b])/2


    del v[a]
    del v[a]

    v.append(ans)


    v.sort()

print(ans)

Submission status: Wrong Answer

Solution code:
def execute(a_array):
    sum_result = []
    for i in range(len(a_array)):
        if i == len(a_array) -1:
            break
        result = (a_array[i] + a_array[i+1]) / 2
        sum_result.append((result, i))
    
    sum_result.sort()
    true_result = sum_result[0]
    a_array.pop(true_result[1])
    a_array.pop(true_result[1])
    
    a_array.append(true_result[0])
    if len(a_array) == 1:
        print(a_array[0])
    else:
        execute(a_array)

import sys
a = []
for l in sys.stdin:
    a.append(l)

a_array = a[1].split(' ')
execute([int(i) for i in a_array])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

if n>=3:
    ai=a[0]
    aii=a[1]
    aiii=a[2]
    al=(aii+aiii)/2
    ans=(al+ai)/2

if n==2:
    ans=(a[0]+a[1])/2
if n==1:
    ans=a[0]

print('{:.6f}'.format(ans))

Submission status: Wrong Answer

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

a = 0
li.sort()
if n == 2:
    print((li[0] + li[1])/2)
elif n >=3:
    for i in range(n-2):
        a = (li[i] + li[i+1])/2
print((a+li[-1])/2)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(map(int,input().split()))
min_ave = 100000
for i, val in enumerate(s):
    for j, val2 in enumerate(s):
        if i == j:
            continue
        ave = (val + val2) / 2
        if min_ave > ave:
            min_ave = ave 
print((max(s) + min_ave)/2)

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
# v = sort(v)
if n < 1:
    print(0)
if n <= 2:
    print(sum(v) / 2)
else:
    for i in range(n):
        vmax = max(v)
        v2 = sorted(v)[-2]
        v3 = sorted(v)[-3]
        vv = (v2 + v3) / 2
    print((vmax + vv) / 2)

Submission status: Wrong Answer

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

v.sort()
ans = None

V = []
a = None
b = None
for i in range(1, N):
    V.append(abs(v[i]-v[i-1]))

for i in range(N-1):
    mi = 10000
    for j in range(1,len(v)):
        if mi >= abs(v[j]-v[j-1]):
            mi = abs(v[j]-v[j-1])
            a = j-1
            b = j
    
    ans = (v[a]+v[b])/2



    if len(v) != 2:
        del v[a]
        del v[a]
    else:
        pass
    v.append(ans)


    v.sort()

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = [int(i) for i in input().split()]
vmax = max(v)
if N%2 == 0:
  print(sum(v)/N)
else:
  print(((sum(v)-vmax)/(N-1)+vmax)/2)

Submission status: Wrong Answer

Solution code:
n = int(input())
listV =  list(map(int,input().split()))
sortedListV = sorted(listV)

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

v = sorted(v)
print(v)
a = v.pop(0)
b = v.pop(0)

result = (a + b)/2
while len(v) > 0:
    a = v.pop(0)
    print(a)
    b = result
    result = (a + b)/2

print(result)

Submission status: Wrong Answer

Solution code:
from queue import Queue
import itertools
q = Queue()
N = int(input())
v = []
v = list(map(int, input().split()))
result = []
old_max = 0
new_max = 0
tmp = 0
comb = list(itertools.combinations(v, 2))
if len(comb) == 1:
    left,right = comb[0]
    print((left + right)/2)
    exit()
for i in range(len(comb)):
    left,right = comb[i]
    calc = (left + right) / 2
    tmp_lis = v.copy()
    tmp_lis.remove(left)
    tmp_lis.remove(right)
    for i in range(len(tmp_lis)):
        new_max = (calc + tmp_lis[i])/2
        if old_max < new_max:
            old_max = new_max
        calc = new_max
    result.append(old_max)

print(int(max(result)))

Submission status: Wrong Answer

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

test = sorted(v)[:2]

print(((sum(test) / 2) + v[0])/2)

Submission status: Wrong Answer

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

while len(v) > 1:
	ans = (v.pop() + v.pop()) / 2
	v.insert(0, ans)
print(v[0])

Submission status: Wrong Answer

Solution code:
N = int(input())

v = list(map(int,input().split()))
         
if N == 2:
  print(sum([int(i) for i in v])/2)
  exit()
  
else:
  v.sort(reverse=True)
  a = v[0]
  v.pop(0)
  r = (a + (sum([int(i) for i in v])/(N-1))) / 2
  print(r)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ai=a[0]
aii=a[1]
aiii=a[-1]
al=(ai+aii)/2
am=(ai+aiii)/2
ans=(al+am)/2

print('{:.6f}'.format(ans))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/

import math
import statistics

# fact(int)
def fact(n):
  if(n == 1):
    return 1
  else:
    return (n * fact(n - 1))

# gcd(int,int)
def gcd(a,b):
  if a == 0:
    return b
  elif b == 0:
    return a
  else:
    return gcd(b,a % b)

# lcm(int,int)
def lcm(a,b):
  return (a * b / gcd(a,b))

# qsort(array[])
def qsort(seq):
  if len(seq) < 1:
      return seq
  pivot = seq[0]
  left = []
  right = []
  for x in range(1, len(seq)):
    if seq[x] <= pivot:
        left.append(seq[x])
    else:
        right.append(seq[x])
  left = qsort(left)
  right = qsort(right)
  foo = [pivot]
  return (left + foo + right)

# = map(int, input().split())
n  = int(input())
#  = raw_input().split()
v  = list(int(i) for i in input().split())  
lastguzai = 0.00

for i in range(n):
  vs = sorted(v)
  if len(v) == 2:
    lastguzai = (v[0] + v[1]) / 2.00
    break
  print(vs)
  v = vs
  lastguzai = (v[0] + v[1]) / 2.00
  del v[0]
  del v[0]
  
  v.append(lastguzai)
  # print(v)

print('{:.6f}'.format(lastguzai))

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
l = readl()
mx = 0
def func(i, ll, s, size):
    global mx
    if size == 0:
        mx = max(mx, ll[0])
        return mx
    t = list(ll)
    base = t[i]
    t.pop(i)
    for j in range(size):
        p = t[0]
        p2 = (base + t[0]) / 2
        t.pop(0)
        t.append(p2)
        func(j, list(t), p2, size - 1)
        t.pop(-1)
        t.append(p)
for i in range(n):
    func(i, list(l), 0, n - 1)
print(mx)

Submission status: Wrong Answer

Solution code:
N=int(input())
v=input().split()
V=v.sort()
cnt=0
while cnt<N-1:
    v[0]=(int(v[0])+int(v[cnt+1]))/2
    cnt+=1
print(v[0])

Submission status: Wrong Answer

Solution code:
from queue import Queue
import itertools
q = Queue()
N = int(input())
v = []
v = list(map(int, input().split()))
result = []
old_max = 0
new_max = 0
tmp = 0
comb = list(itertools.combinations(v, 2))
if len(comb) == 1:
    left,right = comb[0]
    print((left + right)/2)
    exit()
for i in range(len(comb)):
    left,right = comb[i]
    calc = (left + right) / 2
    tmp_lis = v.copy()
    tmp_lis.remove(left)
    tmp_lis.remove(right)
    for i in range(len(tmp_lis)):
        new_max = (calc + tmp_lis[i])/2
        if old_max < new_max:
            old_max = new_max
        calc = new_max
    result.append(old_max)

print(max(result))

Submission status: Wrong Answer

Solution code:
n = int(input())
listV =  list(map(int,input().split()))
sortedListV = sorted(listV)

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

Submission status: Wrong Answer

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

x = (sv[0]+sv[1])/2
y = (x + sv[n-1])/2

print(y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# ABC138C

n = int(input())
v = list(map(int, input().split()))
print(v)
while len(v) > 1:
    a = min(v)
    v.remove(a)
    print(a,v)
    b = min(v)
    v.remove(b)
    print(b,v)
    c = (a + b) / 2
    v.append(c)
    
print(v.pop())

Submission status: Wrong Answer

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

print((B+A[N-1])/2)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
import sys
def main():
    N = int(input())
    lists = list(map(float, input().split()))
    lists.sort()

    for i in range(N-1):
        new_guzai = (lists[0] + lists[1]) / 2

        for _ in range(2):
            lists.pop(0)

        lists.append(float(new_guzai))
        if len(lists) ==1:
            print(lists[0])
            sys.exit()


if __name__ == '__main__' :
    main()

Submission status: Wrong Answer

Solution code:
def find(s):
    k = []
    for i in range(len(s)):
        for j in range(len(s)):
            if(i!=j):
                k.append([abs(s[i]-s[j]),s[i],s[j],(s[i]+s[j])/2])
    #print(k)
    f = min(k)
    return f
    
n = int(input())
s = list(map(int,input().split()))
while(len(s)!=1):
    cur = find(s)
    #print(s)
    s = [i for i in s if i!=cur[1] and i!=cur[2]]
    s.append(cur[3])
print(s[0])

Submission status: Wrong Answer

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

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

print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
listV =  list(map(int,input().split()))
sortedListV = sorted(listV)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/

import math
import statistics

# fact(int)
def fact(n):
  if(n == 1):
    return 1
  else:
    return (n * fact(n - 1))

# gcd(int,int)
def gcd(a,b):
  if a == 0:
    return b
  elif b == 0:
    return a
  else:
    return gcd(b,a % b)

# lcm(int,int)
def lcm(a,b):
  return (a * b / gcd(a,b))

# qsort(array[])
def qsort(seq):
  if len(seq) < 1:
      return seq
  pivot = seq[0]
  left = []
  right = []
  for x in range(1, len(seq)):
    if seq[x] <= pivot:
        left.append(seq[x])
    else:
        right.append(seq[x])
  left = qsort(left)
  right = qsort(right)
  foo = [pivot]
  return (left + foo + right)

# = map(int, input().split())
n  = int(input())
#  = raw_input().split()
v  = list(int(i) for i in input().split())  
lastguzai = 0.00

for i in range(n):
  vs = sorted(v)
  if len(v) == 2:
    lastguzai = (v[0] + v[1]) / 2.00
    break
  # print(vs)
  v = vs
  lastguzai = (v[0] + v[1]) / 2.00
  del v[0]
  del v[1]
  v.append(lastguzai)

print('{:.10f}'.format(lastguzai))

Submission status: Wrong Answer

Solution code:
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
v_list = list(map(int, inputs[1].split()))
v = sorted(v_list)

v_diff_list = [v[i+1] - v[i] for i in range(len(v)-1)]
for _ in range(len(v)-1):
    v_diff_list = [v[i+1] - v[i] for i in range(len(v)-1)]
    index = v_diff_list.index(min(v_diff_list))
    val = (v.pop(index) + v.pop(index)) / 2
    v.insert(index, val)
print(val)

Submission status: Wrong Answer

Solution code:
N=int(input())
vlist=[int(n) for n in input().split()]
vl=sorted(vlist,reverse=True)
Ans=vl[0]
for i in vl:
    Ans = (Ans+i)/2
print(Ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
V = [int(a) for a in input().split()]

V = sorted(V)
for v in V:
    if len(V)==1:
        break
    a = V.pop(0)
    b = V.pop(0)
    V.append((a+b)/2)
print(V[0])

Submission status: Wrong Answer

Solution code:
from collections import deque

N = int(input())
v = list(map(int, input().split()))
v.reverse()
V = deque(v)
sum = 0
while True:
    sum = (V.popleft() + V.popleft())/2
    V.append(sum)
    if len(V) == 1:
        break

print(V[0])

Submission status: Wrong Answer

Solution code:
from queue import Queue
import itertools
q = Queue()
N = int(input())
v = []
v = list(map(int, input().split()))
result = []
old_max = 0
new_max = 0
tmp = 0
comb = list(itertools.combinations(v, 2))
if len(comb) == 1:
    left,right = comb[0]
    print((left + right)/2)
    exit()
for i in range(len(comb)):
    left,right = comb[i]
    calc = (left + right) / 2
    tmp_lis = v.copy()
    tmp_lis.remove(left)
    tmp_lis.remove(right)
    for i in range(len(tmp_lis)):
        new_max = (calc + tmp_lis[i])/2
        if old_max < new_max:
            old_max = new_max
    result.append(old_max)

print(max(result))

Submission status: Wrong Answer

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

v.sort()

i = 0
while i <= N-2:
  v[i+1]=(int(v[i])+int(v[i+1]))/2
  i += 1
  

print(int(v[-1]))

Submission status: Wrong Answer

Solution code:
from collections import deque
import itertools

N = int(input())
V = list(map(int, input().split()))
l = list(itertools.permutations(V))
r = list()
for lo in l:
    d = deque(lo)
    while(len(d) != 1):
        d.append((d.popleft() + d.popleft()) / 2)
    r.append(d)
print(max(r).popleft())

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int, input().split()))
# v = sort(v)
if n <= 2:
    print(sum(v) / 2)
else:
    for i in range(n):
        vmax = max(v)
        v2 = sorted(v)[-2]
        v3 = sorted(v)[-3]
        vv = (v2 + v3) / 2
    print((vmax + vv) / 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
v = [int(i) for i in input().split()]
print(sum(v)/N)

Submission status: Wrong Answer

Solution code:
n = int(input())
num_list = sorted(list(map(int, input().split())))
def merge(num_list):
    if len(num_list) == 1: return num_list
    if len(num_list) ==2: 
        return [(num_list[0] + num_list[1])/2]
    else:
        tmp = num_list[2:]
        tmp.append((num_list[0] + num_list[1])/2)
        return tmp

for i in range(n-1):
    num_list = merge(num_list)
print(num_list[0])

Submission status: Wrong Answer

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

v = sorted(v)
print(v)
def dfs (l):
    if len(l)==1:
         return l[0]
    num = (l[0]+l[1])/2.0
    l = l[2:]
    # print(l)
    l.append(num)
    # print(l)
    l = sorted(l)
    return dfs(l)



print(dfs(v))

Submission status: Wrong Answer

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

for i in range(N-1):
  B = (A[i] + A[i+1])/2

print((B+A[N-1])/2)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

N = input()
N = int(N)

v = []
v = input().split()
v.sort()

for i in range(N - 1) :
	v[i + 1] = (int(v[i]) + int(v[i + 1])) / 2

print(v[i + 1])

Submission status: Wrong Answer

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

v.sort()

i = 0
while i <= N-2:
  v[i+1]=(int(v[i])+int(v[i+1]))/2
  i += 1
  

print(v[i])

Submission status: Wrong Answer

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

while(len(l)>1):
    sorted(l)
    tmp = (l[0] + l[1])/2
    l.append(tmp)
    l.pop(0)
    l.pop(0)

print(l[0])

Submission status: Wrong Answer

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

v.sort()

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

print(s)

Submission status: Wrong Answer

Solution code:
def my_sort(a_array):
    a_array.sort()
    return a_array

def execute(a_array):
    new_array = my_sort(a_array)
    sum_num = (int(new_array.pop(0)) + int(new_array.pop(0))) / 2
    new_array.append(sum_num)
    if len(new_array) == 1:
        print(new_array[0])
    else:
        execute(new_array)

import sys
a = []
for l in sys.stdin:
    a.append(l)

a_array = a[1].split(' ')
execute([int(i) for i in a_array])

Submission status: Wrong Answer

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

n_list.sort()

new_list = []
ctr = 0

while len(n_list) > 1:
  n_list[ctr] = (n_list[ctr] + n_list[ctr+1])/2
  n_list.pop(ctr + 1)
  n_list.sort
  
print(n_list)

Submission status: Wrong Answer

Solution code:
import numpy as np

number = int(input())
input_a_list = list(map(int, input().split()))

input_a_nparray = np.array(input_a_list)
sorted_input_a_nparray = np.sort(input_a_nparray)

max_sum = 0

for t in range(0, number*number):
    sorted_input_a_nparray = np.random.permutation(np.sort(input_a_nparray))

    while len(sorted_input_a_nparray) > 1:
        sorted_input_a_nparray[1] = (sorted_input_a_nparray[0] + sorted_input_a_nparray[1])/2
        sorted_input_a_nparray = np.delete(sorted_input_a_nparray, 0)
    
    if(sorted_input_a_nparray[0] > max_sum):
        max_sum = sorted_input_a_nparray[0]

print(max_sum)

Submission status: Wrong Answer

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

if N % 2:
    v.sort(reverse=True)
    nv = sum(v[1:])/(N-1)
    print((nv+v[0])/2)
else:
    print(sum(v)/N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(((sum(li)-max(li))/(len(li)-1) + max(li))/2 )

Submission status: Wrong Answer

Solution code:
from fractions import Fraction


def main():

    N = int(input())
    elements = list(map(int,input().split()))
    elements.sort()

    while(len(elements)!=1):
        left = elements.pop(0)
        right = elements.pop(0)
        newElement = (left+right)/2
        elements.append(newElement)
    print(elements[0])



if __name__== "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
listV =  list(map(int,input().split()))
sortedListV = sorted(listV)
result = (sortedListV[0] + sortedListV[1]) / 2

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

Submission status: Wrong Answer

Solution code:
def main():
  N = int(input())
  v = [int(i) for i in input().split()]
  v.sort()
  ans = 0
  for i in range(len(v)-1):
    ans = (ans+v[i+1])/2 if i > 0 else (v[i]+v[i+1])/2


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
num = int(input())
V = [int(x) for x in input().split()]
kekka = []
i = 0
while (i + 1) < len(V):
  hi = (V[i] + V[i + 1]) / 2
  kekka.append(hi)
  if hi > max(V):
    V.append(hi)
  i += 1
  
print(max(kekka))

Submission status: Wrong Answer

Solution code:
def my_sort(a_array):
    a_array.sort()
    a_array.reverse()
    return a_array

def execute(a_array):
    new_array = my_sort(a_array)
    sum_num = (int(new_array.pop(0)) + int(new_array.pop(0))) / 2
    new_array.append(sum_num)
    if len(new_array) == 1:
        print(new_array[0])
    else:
        execute(new_array)

import sys
a = []
for l in sys.stdin:
    a.append(l)

a_array = a[1].split(' ')
execute([int(i) for i in a_array])

Submission status: Wrong Answer

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

v = list(map(lambda x: int(x), v))
for i in range(n-1):
  v.sort()
  v.append((v.pop()+v.pop())/2)
print(v[0])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=input().split(" ")
A=[int(i) for i in A]
A.sort()

ans=A[0]/(2*(N-1))
for i in range(1,N):
  ans+=A[i]/(2*(N-i))
print(ans)

Submission status: Wrong Answer

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

if N % 2:
    print(sum(v)/N)
else:
    v.sort(reverse=True)
    nv = sum(v[1:])/(N-1)
    print((nv+v[0])/2)

Submission status: Wrong Answer

Solution code:
import heapq

n = int(input())
hp = []
d = 1 << (n - 1)
for v in (d * int(s) for s in input().split()):
    heapq.heappush(hp, v)
for i in range(n - 1):
    x = heapq.heappop(hp)
    y = heapq.heappop(hp)
    print(x, y)
    heapq.heappush(hp, (x + y) / 2)
print('%.6f' % (hp[0] / d))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[x for x in map(int,input().split())]
x=0
for i in a:
    x+=1/i
print(1/x)

Submission status: Wrong Answer

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

def aaa(numbers):
    if len(numbers) > 1:
        numbers.sort()
        new_number = (numbers[0] + numbers[1]) / 2
        n_0 = numbers[0]
        n_1 = numbers[1]
        numbers.remove(n_0)
        numbers.remove(n_1)
        numbers.append(new_number)
        aaa(numbers)
    else:
        return numbers[0]
      

aaa(numbers)
aaa(numbers)