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())
List=list(map(int,input().split()))
List.sort()
a= List[1]
for i in range(len(List)):
  a= (a+List[i])/2
print(a)

Submission status: Wrong Answer

Solution code:
num = int(input())
values_list = list(map(int, input().split()))
lst = sorted(values_list)
m = 0
n = m + 2
if num == 2:
    num = 3
else:
    pass
for i in range(num-2):
    c_v = 0.5 * sum(lst[m:n])
    if len(lst) == 2:
        pass
    else:
        c_v = 0.5 * (c_v + lst[n])
    m += 1
print(c_v)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split(" ")))
l.sort()
s1=0.0
for i in range(n):
    s1=s1+l[i]
    s1=s1/2
print(s1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(e) for e in input().split()]
init =(a[0] + a[1])/2
result =init
print('初期値は{}です'.format(init))
for i in range(2, n):
    result += (result + a[i])/2
print(result)

Submission status: Wrong Answer

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

dps = 0

while len(lv) > 1:
    i = 1
    j = 0
    prev = lv[j]
    ld = []
    while len(lv) > i:
        ld.append([(lv[i] - prev), j, i])
        prev = lv[i]
        j = i
        i += 1

    ld = sorted(ld, key=lambda x: x[0])
    #print(ld)
    #print(lv)

    a = lv.pop(ld[0][1])
    b = lv.pop(ld[0][2] - 1)
    lv = list(map(lambda x: 2*x, lv))
    lv.append((a+b))
    
    lv = sorted(lv)

    dps += 1

print(lv[0] / (2**dps))

Submission status: Wrong Answer

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

# V.sort(reverse = True)
V.sort()
# print(V)
result = V[0]

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

print(result)

Submission status: Wrong Answer

Solution code:
num = int(input())
values_list = list(map(int, input().split()))
lst = sorted(values_list)
m = 0
n = m + 2
if num == 2:
    num = 3
for i in range(num-2):
    c_v = 0.5 * sum(lst[m:n])
    if len(lst) == 2:
        pass
    else:
        c_v = 0.5 * (c_v + lst[n])
    m += 1
print(c_v)

Submission status: Wrong Answer

Solution code:
N = int(input())
x = list(map(int,input().split()))
x.sort()
p = []

while True:
  for j in range(0,N,2):
    if len(x)%2 == 0:
      p.append((x[j] + x[j+1])/2) 
    else:
      if j != N-1:
        p.append((x[j] + x[j + 1]) / 2)
      else:
        p.append(x[-1])
    
      
  else:
    x = p
    if len(p) == 1:
      break
    p = []
    N = len(x)
print(p[0])

Submission status: Wrong Answer

Solution code:
N = int(input().rstrip())
v = input().rstrip().split(" ")
v.sort()
#print(v)
a = (int(v[0])+int(v[1])) / 2
i = 2
while i <= (N-1):
  a = (a + int(v[i])) / 2
  i += 1
print(':.6f'.format(a))

Submission status: Wrong Answer

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

V.sort(reverse = True)
# print(V)
result = V[0]

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

print(result)

Submission status: Wrong Answer

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

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


while len(diffs) != 1:
    index, min_ = min(enumerate(diffs), key = lambda x:x[1])

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

    del diffs[index]

print(max_-diffs[0]/2)

Submission status: Wrong Answer

Solution code:
N = int(input().rstrip())
v = input().rstrip().split(" ")
v.sort()
#print(v)
a = (int(v[0])+int(v[1])) / 2
i = 2
while i <= (N-1):
  a = (a + int(v[i])) / 2
  i += 1
print(a)

Submission status: Wrong Answer

Solution code:
num = int(input())
lists = sorted(map(int, input().split()))[::-1]

tmp = 0.0

for _ in range(len(lists) - 1):
    x = lists.pop()
    y = lists.pop()
    lists.append((x + y) / 2)
    lists.reverse()

print(lists[0])

Submission status: Wrong Answer

Solution code:
N=int(input())
vn=[int(k) for k in input().split()]

def sort(vn):
    for i in range(0,len(vn)-1):
        select_min(vn,i)

def select_min(vn,i):
    min=i
    for j in range(i+1,len(vn)):
        if vn[min]>vn[j]:
            min=j
    vn[i],vn[min]=vn[min],vn[i]

sort(vn)
for l in range(0,len(vn),2):
    vn.insert(l+2,(vn[l]+vn[l+1])/2)
    
if N<=3:   
    print(vn[-1])
else:
    print((vn[-1]+vn[-2])/2)

Submission status: Wrong Answer

Solution code:
n=input()
a=input().split(' ')
b = []
for i in range(int(n)):
  b.append(int(a[i]))
  
while len(b) >1:
  x=max(b)
  b.remove(x)
  y=max(b)
  b.remove(y)
  b.append((x+y)/2)
  
print(b[0])

Submission status: Wrong Answer

Solution code:
num = int(input())
values_list = list(map(int, input().split()))
lst = sorted(values_list)
m = 0
n = m + 2
if num <= 2:
    num = 3
for i in range(num-2):
    c_v = 0.5 * sum(lst[m:n])
    if num - 2 == 1:
        pass
    else:
        c_v = 0.5 * (c_v + lst[n])
    m += 1
print(c_v)

Submission status: Wrong Answer

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):
            yi_ = len(elements) - 1 - yi
            if xi == yi_:
                continue
            if x ==  elements[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()))
selection(ary)

print (maximum)

Submission status: Wrong Answer

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 main():
    n = int(input())
    v = list()

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

    # 具材が一つの時はその値が解
    if n == 1:
        print(v[0])

    v = [v]

    ans = list()
    for i in v:
        if len(i) != 1:
            new = func(i)

            if len(new[0]) == 1:
                ans.extend(new)
            else:
                # 新たにできた具材のセットを足す
                v.extend(new)

    print(max(ans)[0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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):
            yi_ = len(elements) - 1 - yi
            if xi == yi_:
                continue
            if x ==  elements[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)
            if xi < yi_:
                return


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

print (maximum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
v = list(map(int,input().split()))
v_new = 0
#新しい具材の価値をv_newとした
a = 0
k = []
#kで
p = N
for i in range(N-1):
    #全ての要素が同じ場合は終了する
    if v.count(v[0]) == p:
        break
    else:
       x = v[(math.ceil(len(v)/2))]
       v.remove(x)
       #xをvのリストから除外
       for j in range(len(v)):
           k.append(v[j])
       for j in range(len(k)):
           k[j] = abs(k[j]-x)
       a = k.index(min(k))
       y = v[a]
       k.clear()
       #kのリストを初期化
       v_new = (x+y)/2
       #価値を(x+y)/2とした
       v.append(v_new)
       #v_newをvのリストに挿入
       v.remove(y)
       #yをvのリストから除外
       v_new = 0
       #v_newを初期化
       p = p-1
       a = 0
       x = 0
       y = 0
print(v[0])

Submission status: Wrong Answer

Solution code:
import itertools

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

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

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

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

print(*ans)

Submission status: Wrong Answer

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

N = input()
N = int(N)

v = []
v = input().split()
v = [int(n) for n in v]
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:
#!/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 main():
    n = int(input())
    v = list()

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

    # 具材が一つの時はその値が解
    if n == 1:
        print(v[0])

    v = [v]

    ans = list()
    for i in v:
        if len(i) != 1:
            new = func(i)

            if len(new[0]) == 1:
                ans += new
            else:
                # 新たにできた具材のセットを足す
                v += new

    print(max(ans)[0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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):
            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()))
selection(list(set(ary)))

print (maximum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools

N = int(input())

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


if N == 2:
    print((A[0] + A[1]) / 2)
    sys.exit()

list = []

for i in itertools.permutations(A):
    list.append(i)


countList = []

for i in list:
    count = 0
    for k in range(len(i) - 1):
        if count == 0:
            count = (i[k] + i[k + 1]) / 2
        else:
            count = (count + i[k + 1]) / 2
            countList.append(count)

print(max(set(countList)))

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
v = list(map(int,input().split()))
v_new = 0
#新しい具材の価値をv_newとした
a = 0
k = []
#kで
p = N
for i in range(N-1):
    #全ての要素が同じ場合は終了する
    if v.count(v[0]) == p:
        break
    else:
       x = v[(math.ceil(len(v)/2))]
       v.remove(x)
       #xをvのリストから除外
       for j in range(len(v)):
           k.append(v[j])
       for j in range(len(k)):
           k[j] = abs(k[j]-x)
       a = k.index(min(k))
       y = v[a]
       k.clear()
       #kのリストを初期化
       v_new = (x+y)/2
       v.append(v_new)
       #v_newをvのリストに挿入
       v.remove(y)
       #yをvのリストから除外
       v_new = 0
       #v_newを初期化
       p = p-1
       a = 0
print(v[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
v = input().split()
v.sort()
for i in range(N-1):
  x = (float(v[0]) + float(v[1])) / 2
  x = str(x)
  v.append(x)
  #print(v)
  if len(v) != 1:
    v.pop(0)
    v.pop(0)
  v.sort()
print(float(v[0]))

Submission status: Wrong Answer

Solution code:
N = int(input())
V = list(map(int, input().split()))
alist = []
tmp = 0
i = 0

def cook(N, V, alist, tmp, i):
    if N == 1:
        print(V[0])
    
    else:
        V.sort()
        while i < N:
            if i + 1 > N - 1:
                alist.append(V[i])
                
            else:
                tmp = (V[i] + V[i +1]) / 2
                alist.append(tmp)
                
                i += 2
            
        N = len(alist)
        V = alist
        alist = []
        tmp = 0
        i = 0
        cook(N, V, alist, tmp, i)
        
cook(N, V, alist, tmp, i)

Submission status: Wrong Answer

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

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())
s = list(map(int,input().split()))
if len(s) == 2:
    print((s[0] + s[1]) / 2)
    exit()
max_ave = 0
for i, val in enumerate(s):
    for j, val2 in enumerate(s):
        if i == j or max(s) == val or max(s) == val2: 
            continue
        ave = (val + val2) / 2
        ave = (max(s) + ave) /2 
        if max_ave < ave:
            max_ave = ave 
print(max_ave)

Submission status: Wrong Answer

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

for i in range(N):
    v[i] = float(v[i])
    
v.sort()
ite = 0
while(ite < N-1):
    v[ite+1] = (v[ite]+v[ite+1])/2
    v[ite] = 0
    v.sort()
    print(v)
    ite += 1

print(v[-1])

Submission status: Wrong Answer

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 main():
    n = int(input())
    v = list()

    # 具材が一つの時はその値が解
    if n == 1:
        print(v[0])

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

    v = [v]

    ans = list()
    for i in v:
        if len(i) != 1:
            new = func(i)

            if len(new[0]) == 1:
                ans += new
            else:
                # 新たにできた具材のセットを足す
                v += new

    print(max(ans)[0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

# 空白区切りの整数を取得
li = map(int, raw_input().split())

# 降順ソート
li.sort(reverse=True)

# 最小値同士を計算した結果を末尾に格納
for i in xrange(N-1,0,-1):
    tmp = (li.pop(i) + li.pop(i-1))/2
    li.append(tmp)

print tmp

Submission status: Wrong Answer

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

for i in range(N):
    v[i] = int(v[i])
v.sort()
ite = 0
while(ite < N-1):
    v[ite+1] = (int(v[ite])+int(v[ite+1]))/2
    v[ite] = 0
    #v.sort()
    ite += 1

print(v[-1])

Submission status: Wrong Answer

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 main():
    n = int(input())
    v = list()

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

    v = [v]

    ans = list()
    for i in v:
        if len(i) != 1:
            new = func(i)

            if len(new[0]) == 1:
                ans += new
            else:
                # 新たにできた具材のセットを足す
                v += new

    print(max(ans)[0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if N % 2:
    v_last = v_n[N-1]
else:
    v_last = None

while len(v_n) > 1:
    w_n = [0] * (len(v_n)//2)
    for i in range(len(w_n)):
        j, k = i*2, i*2+1
        w_n[i] = (v_n[j] + v_n[k]) / 2
    v_n = w_n

if v_last is None:
    ans = v_n[0]
else:
    ans = (v_n[0]+v_last) / 2
print(ans)

Submission status: Wrong Answer

Solution code:

N = int(input())

v = list(map(int, input().split())) # Ni個目の具材の価値

if len(v) <= 2:
    print(sum(v) / 2)
else:
    v = list(sorted(v))

    result = 0

    while(True):

        new_list = []
        for i in list(range(0, len(v), 2)):
            l = v[i:i+2]
            if len(l) % 2 == 0:
                new_list.append(sum(l) / 2)
            else:
                new_list.append(l[-1])

        v = list(sorted(new_list))

        if len(v) <= 2:
            break

    print(sum(v) / 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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)
            if xi > yi_:
                return


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

print (maximum)

Submission status: Wrong Answer

Solution code:
N=int(input())
vn=[int(k) for k in input().split()]

def sort(vn):
    for i in range(0,len(vn)-1):
        select_min(vn,i)

def select_min(vn,i):
    min=i
    for j in range(i+1,len(vn)):
        if vn[min]>vn[j]:
            min=j
    vn[i],vn[min]=vn[min],vn[i]

sort(vn)
for l in range(0,len(vn),2):
    vn.insert(l+2,(vn[l]+vn[l+1])/2)
    
print(vn[-1])

Submission status: Wrong Answer

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:
        return elements[0]

    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)
            if xi > yi_:
                return


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

print (maximum)

Submission status: Wrong Answer

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

N=3
li = [500,300,200]
res = 0

for i in xrange(N-1,0,-1):
    tmp = (li.pop(i) + li.pop(i-1))/2
    li.append(tmp)

print tmp

Submission status: Wrong Answer

Solution code:
from collections import deque
import itertools

N = int(input())
V = list(map(int, input().split()))
l = map(list, itertools.permutations(V))
r = list()
for lo in l:
    i = 0
    while (i + 1< len(lo)):
        if ((lo[i] + lo[i + 1]) / 2) not in lo:
            lo.append((lo[i] + lo[i + 1]) / 2)
        i+=2
    r.append(lo[-1])

print(max(r))

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=(ai+aii)/2
    all=(al+aiii)/2
    am=(aii+aiii)/2
    amm=(am+ai)/2
    an=(ai+aiii)/2
    ann=(an+aii)/2
    ans=max(all,amm,ann)

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())
v = list(map(float,input().split()))
v_list = sorted(v)
for i in range(n-1):
    a = (v_list[0]+v_list[1])/2
    v_list.append(a)
    v_list = sorted(v_list)
    del(v_list[0])
    del(v_list[1])

    
print(v_list)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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):
            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)
            if xi > yi_:
                return


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

print (maximum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

SUM = 0
for i in range(N):
    v[i] = int(v[i])
v.sort()
ite = 0
while(ite < N-1):
    v[ite+1] = (int(v[ite])+int(v[ite+1]))/2
    v[ite] = 0
    v.sort()
    #print(v)
    ite += 1

print(v[-1])

Submission status: Wrong Answer

Solution code:
n=int(input())
v=input().split()
w=sorted(v)
a=1
x=int(w[0])
while a<=n-1:
  y=int(w[a])
  z=x+y
  x=float(z)/float(2)
  a=a+1
print(x)

Submission status: Wrong Answer

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

def yo(A):
  ans=A[0]/(2*(len(A)-1))
  for i in range(1,len(A)):
    ans+=A[i]/(2*(len(A)-i))
  return ans

def act(A):
  if len(A)%2==0:
    A_=[]
    for i in range(int(len(A)/2)):
      A_.append((A[2*i]+A[2*i+1])/2)
    return A_
  
  elif len(A)%2==1:
    A_=[]
    for i in range(int((len(A)-1)/2)):
      A_.append((A[2*i]+A[2*i+1])/2)
    A_.append(A[len(A)-1])
    return A_
    
li=[]
while len(A)>1:
  li.append(yo(A))
  A=act(A)

li.append(A[0])
print(max(li))

Submission status: Wrong Answer

Solution code:
n = int(input())
v = list(map(int,input().split()))
i = len(v)-1

for i in range(n-1):
    v.sort()
    new_num = (v[0] + v[len(v)-1]) / 2
    v[0] = new_num
    if i != n - 1:
        v.remove(v[len(v)-1])

print(new_num)

'''
    for j in range((n-1)-i):
        if j == 0:
            v[j] = new_num
        else:
            v.remove(v[len(v)-1])

'''

Submission status: Wrong Answer

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


while len(lv) > 1:
    i = 1
    j = 0
    prev = lv[j]
    ld = []
    while len(lv) > i:
        ld.append([(lv[i] - prev), j, i])
        prev = lv[i]
        j = i
        i += 1
        
    ld = sorted(ld, key=lambda x: x[0])
    #print(ld)
    #print(lv)
    
    a = lv.pop(ld[0][1])
    b = lv.pop(ld[0][2] - 1)
    
    lv.append((a+b)/2)
    lv = sorted(lv)

print(lv[0])

Submission status: Wrong Answer

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

for i in range(N):
    if len(v) == 1:
        pass
    else:
        if min(v) in v:
            aaa =min(v)
            v.remove(min(v))
        if min(v) in v:
            bbb =min(v)
            v.remove(min(v))
            ccc =(aaa + bbb)/2
            v.append(ccc)
print(v)

Submission status: Wrong Answer

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

for i in range(N):
  l.append(2**(i))

l = sorted(l, reverse = True)
  
array_multiple = list(map(lambda x,n: x/n, A, l))

print(sum(array_multiple))

Submission status: Wrong Answer

Solution code:
N=int(input())
v=[int(x) for x in input().split()]
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:
N = int(input())
v = input().split()

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

print(v[-1])

Submission status: Wrong Answer

Solution code:

N = int(input())

v = list(map(int, input().split())) # Ni個目の具材の価値
v = list(sorted(v))

if len(v) <= 2:
    print(sum(v) / 2)
else:

    result = 0

    while(True):

        new_list = []
        for i in list(range(0, len(v), 2)):
            l = v[i:i+2]
            if len(l) % 2 == 0:
                new_list.append(sum(l) / 2)
            else:
                new_list.append(l[0])

        v = list(sorted(new_list))

        if len(v) <= 2:
            break

    print(sum(v) / 2)

Submission status: Wrong Answer

Solution code:
input()
A = list(map(int, input().split()))
A.sort()
while len(A)>1:
  b = A[0:2]
  c = sum(i for i in b)
  A.append(c/2)
  del(A[0:2])
  A.sort()

print(A)

Submission status: Wrong Answer

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

while len(v) != 2:
    sorted(v)
    ave =  (v[0]+v[1])/2
    v.remove(v[0])
    v.remove(v[1])
    v.append(ave)

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

Submission status: Wrong Answer

Solution code:
N=int(input())
v=input().split()
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:

N = int(input())

v = list(map(int, input().split())) # Ni個目の具材の価値
v = list(sorted(v))

if len(v) <= 2:
    print(sum(v) / 2)
else:

    result = 0

    while(True):

        new_list = []
        for i in list(range(0, len(v), 2)):
            print(v[i:i+2])
            l = v[i:i+2]
            if len(l) % 2 == 0:
                new_list.append(sum(l) / 2)
            else:
                new_list.append(l[0])

        v = list(sorted(new_list))

        if len(v) <= 2:
            break

    print(sum(v) / 2)

Submission status: Wrong Answer

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

def act(A):
  if len(A)%2==0:
    A_=[]
    for i in range(int(len(A)/2)):
      A_.append((A[2*i]+A[2*i+1])/2)
    return A_
  
  elif len(A)%2==1:
    A_=[]
    for i in range(int((len(A)-1)/2)):
      A_.append((A[2*i]+A[2*i+1])/2)
    A_.append(A[len(A)-1])
    return A_
    
    
while len(A)>1:
  A=act(A)

print(A[0])

Submission status: Wrong Answer

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

def saiki(*v):
    #print(*v)
    if len(v) == 1:
        return v
    elif len(v) == 2:
        return sum(v)/2
    else:
        return (saiki(*v[1:]) + v[0])/2

print(saiki(*v))

Submission status: Wrong Answer

Solution code:
N = int(input())
v = list(map(int, input().split()))
if len(v) == 2:
    print((v[0] + v[1])/2)
    exit()
cal_lis = []
result = []
new_max = 0
old_max = 0
for i in range(1,len(v)):
    cal_lis = v.copy()
    calc = (v[i] + v[i-1])/2
    cal_lis.remove(v[i])
    cal_lis.remove(v[i-1])
    for j in range(len(cal_lis)):
        new_max = (calc + cal_lis[j])/2
        if old_max < new_max:
            old_max = new_max
            result.append(new_max)
        calc = new_max
print(max(result))

Submission status: Wrong Answer

Solution code:
def max_sum(N,a):
  dp=[0]*(N+1)
  for i in range(N):
    dp[i+1]=max(dp[i],dp[i]+a[i])
  return dp[N]

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

ans = float(max_sum(n, v))/2
print(ans)

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()
max_ave = 100000
for i, val in enumerate(s):
    for j, val2 in enumerate(s):
        if i == j:
            continue
        ave = (val + val2) / 2
        ave = (max(s) + ave) /2 
        if max_ave > ave:
            max_ave = ave 
print(max_ave)