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: Time Limit Exceeded

Solution code:
from itertools import combinations, permutations
N = int(input())
#N,K = map(int,input().split())
#N = int(input())
V = list(map(int,input().split()))
s=0
S=[0]
for C in combinations(V,2):
    n=N
    v=V.copy()
    v.remove(C[0])
    v.remove(C[1])
    s=(C[0]+C[1])/2**(n-1)
    n-=2
    #print(C,s)
    for D in permutations(v):
        m=n
        k=s
        for i in range(m):

            k+=D[i]/(2**m)
            m-=1
        S.append(k)
#        print(k,D)
print(max(S))

Submission status: Time Limit Exceeded

Solution code:
import itertools


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

C = list(itertools.permutations(V, N))
ans = 0
for c in C:
    a = c[0]
    for i in range(1, N):
        a = (a + c[i]) / 2
    ans = max(ans, a)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools


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

C = list(itertools.permutations(V, N))
S = set(C)
ans = 0
for s in S:
    a = s[0]
    for i in range(1, N):
        a = (a + s[i]) / 2
    ans = max(ans, a)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools


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

C = list(itertools.permutations(V, N))

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n = int(input())
v = list(map(float, input().split()))

ans = []
for x in permutations(v):
    p = x[0]
    for i in range(1, n):
        p = (p + x[i])/2.0
    ans.append(p)
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

ans = 0
for vi in itertools.permutations(v):
    point = vi[0]
    for j in range(1,n):
        point = (point+vi[j])/2
    ans = max(point, ans)
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
N=int(input())
gu=list(map(int,input().split()))
ans=[]
for v in itertools.permutations(gu):
    cnt=2
    k=(v[0]+v[1])/2
    while cnt<=N-1:
        k=(k+v[cnt])/2
        cnt+=1
    ans.append(k)
print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())
li = list(map(int, input().split()))
t = []

max = 0

for i in itertools.permutations(range(N)):
  t.append(i)

for i in t:
  count = 0
  for n in range(N-1):
    if n == 0:
      count = (li[i[n]] + li[i[n+1]]) / 2
    else:
      count = (count + li[i[n+1]]) / 2

  if max < count:
    max = count

print(max)

Submission status: Time Limit Exceeded

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

import itertools

p=itertools.permutations(v,len(v))
summary_l=[]

for q in p:
    summary=q[0]
    for i in range(1,N):
        summary=(summary+q[i])/2
    summary_l.append(summary)

print(max(summary_l))

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
food = [int(x) for x in input().split()]

food_p = list(itertools.permutations(food))

max_val = -1

if len(food) == 1:
    print(food[0])
elif len(food) == 2:
    print(sum(food) / 2)
else:
    for p in food_p:
        value = (p[0] + p[1]) / 2
        for val in p[2:]:
            value = (value + val) / 2

        if max_val < value:
            max_val = value

    print(max_val)

Submission status: Time Limit Exceeded

Solution code:
import itertools
n = int(input())
v = list(map(int,input().split()))
values = []
for root in itertools.permutations(v):
  pot = root[0]
  for i in range(n - 1):
    pot = (pot + root[i + 1]) / 2
    if i == n - 2:
      values.append(pot)
print(max(values))

Submission status: Time Limit Exceeded

Solution code:
import itertools

N=int(input())
L=list(itertools.permutations(map(int,input().split())))
ANS=-1
for l in L:
  TMP = l[0]
  for i in range(1, N):
    TMP = (l[i] + TMP) / 2.0
  if ANS <= TMP:
    ANS = TMP
print(ANS)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N=int(input())
L=list(itertools.permutations(map(int,input().split())))
ANS=-1
for l in L:
  ll = list(l)
  TMP = ll[0]
  for i in range(1, N):
    TMP = (ll[i] + TMP) / 2.0
  if ANS <= TMP:
    ANS = TMP
print(ANS)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

result = []
for v in itertools.permutations(list, N):
    avg = 0
    for num in v:
        if avg == 0:
            avg = num
        else:
            avg = (num + avg) / 2
    result.append(avg)

print(max(result))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


def get_answer(n, a):
    n = int(n)
    a = [int(v) for v in a.split(" ")]
    indexes_all = create_index(n)
    v_max = -1
    for indexes in indexes_all:
        v = a[indexes[0]]
        for i in range(1, len(indexes)):
            v = (v + a[indexes[i]]) / 2
        if v > v_max:
            v_max = v
    return v_max


def create_index(n):
    ret_all = []
    index_queue = np.arange(0, n)
    ret = []
    search_index(index_queue, ret_all, ret, n)
    return ret_all


def search_index(index_q, ret_all, ret, n):
    if n <= 0:
        ret_all.append(list(ret))
        return
    for i in range(n):
        index = index_q[i]
        index_q = np.delete(index_q, i)
        ret.append(index)
        search_index(index_q, ret_all, ret, n - 1)
        index_q = np.insert(index_q, i, index)
        ret.pop()


if __name__ == "__main__":
    input1 = input()
    input2 = input()
    print(get_answer(input1, input2))

Submission status: Time Limit Exceeded

Solution code:
import itertools

def calc(vlist):
    sum = vlist[0]
    for i in range(len(vlist) - 1):
        sum = ((sum + vlist[i+1]) / 2)        

    return sum

try:
    n = int(input())
    
    v = [int(x) for x in input().split(' ')]
    
    pattern = itertools.permutations(v)
    
    results = []
    for plist in pattern:
      results.append(calc(plist))
      
    print(max(results))
    
except ValueError:
    print("数値を入力してください")

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
from decimal import Decimal
from itertools import permutations

# 整数の入力
N = int(input())

# スペース区切りの整数の入力
V = list(map(Decimal, input().split()))

result = 0

for values in permutations(V, N):
    new_result = values[0]

    for value in values[1:]:
        new_result = (new_result + value) / 2

    if result < new_result:
        result = new_result

# 出力
print(result)

Submission status: Time Limit Exceeded

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.pop() + d.pop()) / 2)
    r.append(d)
print(max(r).pop())

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
foods = [int(i) for i in input().split()]

#print(list(itertools.permutations(foods)))
result_value = 0
for i in list(itertools.permutations(foods)):

    temp_value = i[0]
    for j in range(1,len(i)):
        temp_value = (temp_value + i[j])/2
    if result_value < temp_value:
        result_value = temp_value

#print(sorted(result_value))
#result_value = sorted(result_value,reverse=True)

print(result_value)

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
data = list(map(int, input().split()))

def comp(a, b):
    r = (a + b) / 2
    return r

ans = []
for d in list(itertools.permutations(data)):

    tmp = d[0]
    for i in range(n-1):
        tmp = comp( tmp, d[i+1])
    
    ans.append(tmp)

print(max(ans))

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
foods = [int(i) for i in input().split()]

#print(list(itertools.permutations(foods)))
result_value = []
for i in list(itertools.permutations(foods)):

    temp_value = i[0]
    for j in range(1,len(i)):
        temp_value = (temp_value + i[j])/2
    result_value.append(temp_value)

#print(sorted(result_value))
result_value = sorted(result_value,reverse=True)

print(result_value[0])

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
List=[int(i) for i in input().split()]
List.sort()
num = 0
ans = []
if a > 2:
 while True:
   try:
    res = (List[num] + List[num+1])/2
    ans.append(res)
    if num < a-2:
     resa = (ans[num] + List[num+2])/2
     num = num + 1
   except:
    break
    print(resa)
else:
 print((List[0] + List[1])/2)

Submission status: Time Limit Exceeded

Solution code:
import copy
maximum = 0

def fusion(x, y):
    return (x + y) / 2.0

def selection(elements):
    global maximum

    if len(list(set(elements))) == 1:
        maximum = max(maximum, elements[0])
        return

    if len(elements) == 2:
        maximum = max(maximum, fusion(elements[0], elements[1]))
        return

    for xi, x in enumerate(elements):
        for yi, y in enumerate(elements):
            yi_ = len(elements) - 1 - yi
            if xi == yi_:
                continue
            new_array = []
            for ei, e in enumerate(elements):
                if ei != xi and ei != yi_:
                    new_array.append(e)

            new_array.append(fusion(x, elements[yi_]))
            selection(new_array)


_ = int(input())
ary = list(map(int,input().split()))
ary.sort()
selection(ary)

print (maximum)

Submission status: Time Limit Exceeded

Solution code:
import copy
maximum = 0

def fusion(x, y):
    return (x + y) / 2.0

def selection(elements):
    global maximum

    if len(list(set(elements))) == 1:
        maximum = max(maximum, elements[0])
        return

    if len(elements) == 2:
        maximum = max(maximum, fusion(elements[0], elements[1]))
        return

    for xi, x in enumerate(elements):
        for yi, y in enumerate(elements):
            yi_ = len(elements) - 1 - yi
            if xi == yi_:
                continue
            new_array = []
            for ei, e in enumerate(elements):
                if ei != xi and ei != yi_:
                    new_array.append(e)

            new_array.append(fusion(x, elements[yi_]))
            selection(new_array)


_ = int(input())
selection(list(map(int,input().split())))

print (maximum)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import itertools
import sys
input = sys.stdin.readline


def func(i):
    ans = list()
    for a in itertools.combinations(i, 2):
        ans.append(
            [(a[0] + a[1]) / 2] + [j for j in i if j not in [a[0], a[1]]])

    return ans


def judge(v):
    for i in v:
        if len(i) != 1:
            return False

    return True


def main():
    n = int(input())
    v = list()

    for i in map(int, input().split()):
        v.append(i)

    v = [v]

    while True:
        for i in v:
            if len(i) != 1:
                v.remove(i)
                new = func(i)
                # 新たにできた具材のセットを足す
                v += new

        if judge(v):
            break

    print(max(v)[0])


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import copy
maximum = 0

def fusion(x, y):
    return (x + y) / 2.0

def selection(elements):
    global maximum

    if len(elements) == 2:
        maximum = max(maximum, fusion(elements[0], elements[1]))
        return

    for xi, x in enumerate(elements):
        for yi, y in enumerate(elements):
            if xi == yi:
                continue
            new_array = []
            for ei, e in enumerate(elements):
                if ei != xi and ei != yi:
                    new_array.append(e)

            new_array.append(fusion(x, y))
            selection(new_array)

_ = int(input())
selection(list(map(int,input().split())))

print (maximum)

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

ans_list = []

def calcurater(a_list):
  ans = (a_list[0] + a_list[1]) / 2
  for a in range(len(a_list) - 2):
    ans = (ans + a_list[a + 2]) / 2

  return ans

for i in itertools.permutations(v):
  ans_list.append(calcurater(list(i)))


print(max(ans_list))

Submission status: Time Limit Exceeded

Solution code:
import itertools
import math

num = int(input())
list_org = input().split()
sequence = list(itertools.permutations(list_org))
kazo = math.factorial(num)
power = [1]
bunbo = 2**(num-1)
max_values = []
for i in range(num-1):
  power.append(2**i)
  
for i in range(kazo):
  a = 0
  for j in range(num):
    a += int(power[j]) * int(sequence[i][j])
  max_values.append(a)
  
print(max(max_values)/bunbo)

Submission status: Time Limit Exceeded

Solution code:
import itertools

n = int(input())
foods = [int(i) for i in input().split()]

result_value = []
for i in list(itertools.permutations(foods)):
    temp_value = i[0]
    for j in range(1,len(i)):
        temp_value = (temp_value + i[j])/2
    result_value.append(temp_value)

result_value = sorted(result_value[::-1],reverse=True)

print(result_value[0])

Submission status: Time Limit Exceeded

Solution code:
import itertools

_ = int(input())
u_list = list(map(int, input().split()))
s_list = []
for s in itertools.permutations(u_list):
    s = list(s)
    _sum = (s.pop(0) + s.pop(0)) / 2
    while s:
        _sum = (_sum + s.pop(0)) / 2
    s_list.append(_sum)
print(max(s_list))

Submission status: Time Limit Exceeded

Solution code:
import itertools

num = int(input())
list_org = input().split()
sequence = list(itertools.permutations(list_org))
kazo = len(sequence)
power = [1]
bunbo = 2**(num-1)
max_values = []
for i in range(num-1):
  power.append(2**i)
for i in range(kazo):
  a = 0
  for j in range(num):
    a += int(power[j]) * int(sequence[i][j])
  max_values.append(a)
  
print(max(max_values)/bunbo)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

n = int(input())
values = list(map(int, input().split()))

ans = 0


def dfs(v):
    if len(v) == 2:
        global ans
        ans = max((v[0] + v[1]) / 2, ans)
        return

    for vv in combinations(v, 2):
        v_alche = v[:]
        v_alche.remove(vv[0])
        v_alche.remove(vv[1])
        v_alche.append((vv[0] + vv[1]) / 2)
        dfs(v_alche)


dfs(values)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import copy

limit = int(input())
vs = list(map(int,input().split()))
selected = []
maximum = 0

for x in vs:
    selected.append(False)

def fusion(x, y):
    # print("fusion {}, {}, {}".format(x, y, (x+y) / 2.0))
    return (x + y) / 2.0

def selection(elements, selected, limit):
    global maximum
    # print(elements)
    # print(selected)
    for xi, x in enumerate(elements):
        if selected[xi] == True:
            continue
        selected[xi] = True
        for yi, y in enumerate(elements):
            if selected[yi] == True:
                continue
            selected[yi] = True

            if len(elements) == 2:
                maximum = max(maximum, fusion(elements[xi], elements[yi]))
                return

            new_array = []
            new_selected = []
            for si, s in enumerate(selected):
                if s == False:
                    new_array.append(elements[si])
                    new_selected.append(False)
            new_selected.append(False)
            new_array.append(fusion(elements[xi], elements[yi]))
            # print("{} {}".format(elements[xi], elements[yi]))
            # # print("limit is {}".format(limit))
            selection(new_array, new_selected, limit)

            selected[yi] = False
        selected[xi] = False

selection(vs, selected, limit-1)

print (maximum)

Submission status: Time Limit Exceeded

Solution code:
from itertools import permutations

n = int(input())
values = list(map(int, input().split()))

ans = 0


def dfs(v):
    if len(v) == 2:
        global ans
        ans = max((v[0] + v[1]) / 2, ans)
        return 0
    for vv in permutations(v, 2):
        v_alche = v[:]
        v_alche.remove(vv[0])
        v_alche.remove(vv[1])
        v_alche.append((vv[0] + vv[1]) / 2)
        dfs(v_alche)


dfs(values)
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Accepted

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

Submission status: Accepted

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

u = sorted(u)
ans = 0

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

Submission status: Accepted

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

v.sort()

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

print(v[-1])

Submission status: Accepted

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

Submission status: Accepted

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

v.sort()
dp = [0]*(n-1)

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

Submission status: Accepted

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

V.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
v=list(map(int,input().split()))
ans=0
while len(v) != 1:
  a=min(v)
  v.remove(a)
  b=min(v)
  v.remove(b)
  ans=(a+b)/2
  v.append(ans)


print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, v: "List[int]"):
    v.sort()
    ans = (v[0] + v[1]) / 2
    for i in range(2, N):
        ans = (ans + v[i]) / 2
    print(ans)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    v = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, v)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

for _ in range(n - 1):
    arr.sort()
    new_v = (arr[0] + arr[1]) / 2
    del arr[0:2]
    arr.append(new_v)

print(arr[0])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


L = []
L.append(v[0])
ANS = 0
for i in range(N-1):
    N = (L[i] + v[i+1])/2
    L.append(N)
    
print(max(L))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
ans = 0
a = 1
for i in range(N):
    if i != N-1:
        a *= 0.5
    ans += a*A[i]

print(ans)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N = int(input())
Val = list(map(int,input().split()))
Val.sort()
for i in range(N-1):
    x = Val.pop(0)
    y = Val.pop(0)
    Val.append((x+y)/2)
    Val.sort()

print(Val[0])

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int,input().split()))
v.sort()
t = float(v[0]+v[1])/2

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


print('{:.05f}'.format(t))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

def main():
    N = int(input())
    v = list(map(int, input().split()))
    v.sort()
    ans = v[0] / 2 ** (N - 1)
    for i in range(1, N):
        ans += v[i] / 2 ** (N - i)

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

v = sorted(v)

ans = v[0]
for num in v[1:]:
    ans = (ans + num)/2

print(ans)

Submission status: Accepted

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

v.sort()
while True:
  x = v[0]
  y = v[1]
  z = (x+y) / 2
  v.pop(0)
  v.pop(0)
  v.append(z)
  v.sort()
  if len(v) == 1:
    break
  else:
    pass
  

print(z)

Submission status: Accepted

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

v.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

guzai.sort()

ave =(guzai[0] + guzai[1])/2

for x in range(2,n):
  ave = (ave + guzai[x])/2
  
print(ave)

Submission status: Accepted

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

v.sort()
tmp = 0.0
for i in range(N):
    if i == 0:
        tmp = v[i]
    else:
        tmp = (tmp+v[i])/2.0

print(tmp)

Submission status: Accepted

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

# 昇順にソートすると、最大値を与えるのは以下の操作を行ったとき：
# v_1 = (v_0 + v_1)/2 (v_0は消滅）
# v_2 = (v_1 + V_2)/2 (v_1は消滅)
# v_(N-1) = (v_(N_1) + v_(N-2))/2 (v_(N-2)は消滅)
# 結局、(N-1)番目の素材が残り、その価値はv_(N-1)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
if N == 2:
  print(sum(A)/2)
  exit()
else:
  temp = (A[0]+A[1])/2
  for i in range(2, N):
    temp = 1/2*(A[i] + temp)
print(temp)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 21:55:15 2020

@author: liang
"""

N = int(input())
V = list(map(int,input().split()))
V.sort(reverse=True)
#print(V)
for i in range(N-1):
    tmp = 0
    tmp += (V.pop() + V.pop())/2
    V.append(tmp)

print(V[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

s = list(map(int, input().split()))

s.sort()

v = 0

if n == 1:
  print(s[0])
  exit()
elif n == 2:
  print((s[0]+s[1])/2)
  exit()

c = (s[0]+s[1])/2

del s[0]
del s[0]

for i in range(n-2):
  c = (c + s[0])/2
  del s[0]
  
  
print(c)

Submission status: Accepted

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

ans = 0
t = 1
for i in range(n-1):
    t *= 2
    ans += v[i] / t
print(ans + v[-1]/t)

Submission status: Accepted

Solution code:
n = int(input())
v = list(map(int, input().split( )))
v1 = sorted(v)
for _ in range(n-1):
  new = (v1[0] + v1[1])/2
  v1 = v1[2:]
  v1.append(new)
  v1 = sorted(v1)
print(v1[0])

Submission status: Accepted

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

v.sort()

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

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

v.sort()

deq = deque(v)

while len(deq) != 1:
    x = deq.popleft()
    y = deq.popleft()
    
    nx = (x+y)/2
    
    deq.appendleft(nx)

ans = deq.popleft()

print(ans)

Submission status: Accepted

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

print(z)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import heapq

def main():
    n = int(input())
    values=[]
    heap_values=[]
    values=list(map(int,input().split()))
    [heapq.heappush(heap_values, value) for value in values]

    while len(heap_values)!=1:
        tmp1=heapq.heappop(heap_values)
        tmp2=heapq.heappop(heap_values)
        tmp_value=(tmp1+tmp2)/2
        heapq.heappush(heap_values,tmp_value)

    print(heap_values[0])

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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(value)

Submission status: Accepted

Solution code:
def cumsum(n,A):
    s = [0]*(n+1)
    s[0] = A[0]
    for i in range(len(A)):
        s[i+1] = (s[i] + A[i])/2
    return s

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

for i in range(n-1):
    s = cumsum(n,v)
print(s[-1])

Submission status: Accepted

Solution code:
n = int(input())
v = sorted(list(map(int,input().split())))
s = [0]*n
s[0] = v[0]

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

Submission status: Accepted

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