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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = map(int,input())
X=[]
for i in range(1,N+1):
    X.append(list(map(int,input().split())))
    
re=0
for i in range(N-1):
    for x in range(1,N+1):
        for y in range(1,N+1):
            new = (X[x]+X[y])/2
            re +

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int n;
priority_queue<double> pq;

int main() {
	cin>>n;
	for(int i = 0;i<n;i++){
		int t;
		cin>>t;
		pq.push(-t*1.0);
	}
	while(pq.size()>1){
		double a = -pq.top();
		pq.pop();
		double b = -pq.top();
		pq.pop();
		pq.push(-(a+b)/2);
	}
	cout<<fixed<<setprecision(10)<<-pq.top();
	// your code goes here
	return 0;
}

Submission status: Runtime Error

Solution code:

N = int(input())
#s = input()
#S = []
#for i in range(N):
S = input().split(" ")
for i in range(N):
    S[i] = int(S[i])
for i in range(N):
    S[i+1] = (int(S[i])+int(S[i+1])) / 2
print(S[N-1])

Submission status: Runtime Error

Solution code:
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
print(1.0/sum(list(map(lambda x: 1.0 / x, a))))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#from functools import reduce
N = int(input())
Xs = list(map(int,input().split()))
Xs_ = sorted(Xs)
print(sum([Xs_[i]* (2**(-n+i-1)) if i != 0 else Xs_[i]*(2**(-n)) for i in range(N)]))

Submission status: Runtime Error

Solution code:
import sys
import os
f = open('input.txt', 'r')
sys.stdin = f
N = int(input())
v = list(map(int, input().split()))
v.sort()
tmp = v[0]
ave = 0
for i in range(1, N):
    tmp += v[i]
    ave = tmp / 2
    tmp = ave
print(ave)

Submission status: Runtime Error

Solution code:
import heapq
N = int(input())
V = list(map(int, input().split()))
heapq.heapify(V)
for i in range(N-2):
  heapq.heappush((heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)

Submission status: Runtime Error

Solution code:
import heapq
N = int(input())
V = list(map(int, input().split()))
 
heapq.heapfy(V)
for i in range(N-2):
  heapq.heappush((heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)

Submission status: Runtime Error

Solution code:
import heapq
N = input()
V = input().split()

heapq.heapfy(V)
for i in range(N-2):
  heapq.heappush((heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)

Submission status: Runtime Error

Solution code:
import itertools as it
import numpy as np
from copy import deepcopy

def main():
    inputs = [input() for _ in range(2)]
    N = int(inputs[0])
    ingredients = [float(i) for i in inputs[1].split(' ')]

    combinations = [list(it.combinations(range(l), 2)) for l in range(2,len(ingredients)+1)]
    combinations.reverse()

    indexes = np.empty((np.prod([len(c) for c in combinations]), len(combinations)), dtype='i')
    for i, combination in enumerate(combinations):
        indexes[:,i] = np.array(list(range(len(combination))) * int(len(indexes)/len(combination)))

    best_ingredient = 0.
    for index in indexes:
        routs = []
        curr_ingredients = deepcopy(ingredients)
        for n,i in enumerate(index):
            routs.append(combinations[n][i])
        for rout in routs:
            new_ingredient = (curr_ingredients.pop(rout[1]) +
                            curr_ingredients.pop(rout[0])) / 2.
            curr_ingredients.append(new_ingredient)
        if best_ingredient < curr_ingredients[0]:
            best_ingredient = curr_ingredients[0]

    print(best_ingredient)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import itertools as it
import numpy as np
from copy import deepcopy

def main():
    inputs = [input() for _ in range(2)]
    N = int(inputs[0])
    ingredients = [float(i) for i in inputs[1].split(' ')]

    combinations = [list(it.combinations(range(l), 2)) for l in range(2,len(ingredients)+1)]
    combinations.reverse()

    indexes = np.empty((np.prod([len(c) for c in combinations]), len(combinations)), dtype='i')
    for i, combination in enumerate(combinations):
        indexes[:,i] = np.array(list(range(len(combination))) * int(len(indexes)/len(combination)))

    best_ingredient = 0.
    for index in indexes:
        routs = []
        curr_ingredients = deepcopy(ingredients)
        for n,i in enumerate(index):
            routs.append(combinations[n][i])
        for rout in routs:
            new_ingredient = (curr_ingredients.pop(rout[1]) +
                            curr_ingredients.pop(rout[0])) / 2
            curr_ingredients.append(new_ingredient)
        if best_ingredient < curr_ingredients[0]:
            best_ingredient = curr_ingredients[0]

    print(best_ingredient)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
V = [float(v) for v in input().split()]
V.sort(revese=True)
for i in range(N):
    if len(V) == 1:
        print(V[0])
        exit()
    v1 = V.pop()
    v2 = V.pop()
    V.append((v1 + v2) / 2)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
vn_list = input().split()

vn = np.array(vn_list, dtype="float")
w = np.geomspace(1/2, 1/(2**N), num=N)
w[N-1] = w[N-2]
result = np.dot(vn, w)
print(result)

Submission status: Runtime Error

Solution code:
def solve(string):
    n, *v = map(int, string.split())
    v = sorted(v, reverse=True)
    return str(sum(_v / 2**i for i, _v in enumerate(v[:-1], start=1)) + v[-1] / 2**(n - 1))


if __name__ == '__main__':
    print(solve(input()))

Submission status: Runtime Error

Solution code:
N = int(input())
list_x = sorted([x for x in input().split()])
out = list_x[0]/(2**(N-1))
for i, x in enumerate(list_x[1:]):
  out += x/(2**(N-1-i))

print(out)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from heapq import heappush, heappop N = int(input()) vLst = list(map(int, input().split())) v = [] for i in range(N): heappush(v, vLst[i]) ans = 0 for i in range(N - 1): tmp1 = heappop(v) tmp2 = heappop(v) ans = float((tmp1 + tmp2) / 2) heappush(v, ans) print(v[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,Q=map(int,input().split())
l=[[1,0,0]]
for i in range(1,N):
    a,b=map(int,input().split())
    l.append([b,a,0])
l.sort()
for i in range(Q):
    p,x=map(int,input().split())
    l[p-1][2]+=x
t=[l[0][2]]
for i in range(1,N):
    t.append(t[l[i][1]-1]+l[i][2])
print(*t)

Submission status: Runtime Error

Solution code:
N=int(input())
a =list(map(int,input().split()))
def myFunction(i):
    if (i == N-2):
        print((a[i-1]+a[i])/2)
    a[i] = (a[i-1]+a[i])/2
    myFunction(i+1)    
a.sort()
myFunction(1)

Submission status: Runtime Error

Solution code:
N=int(input())
a =list(map(int,input().split()))
def myFunction(int i):
    if (i == N-2):
        print((a[i-1]+a[i])/2)
    myFunction(i+1)    
a.sort()
myFunction(1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
a=list(map(int,input().split()))
for i in range(0,N):
	a.sort()
	x,y=map(int,a.pop())
	a.append((x+y)/2)

Submission status: Runtime Error

Solution code:
N=int(input())
a=list(map(int,input().split()))
while len(a)>=2:
	a.sort()
	x,y=map(int,a.pop())
	a.append((x+y)/2)

Submission status: Runtime Error

Solution code:
N=int(input())
a=list(map(int,input().split()))
while len(a)>=2:
	a.sort()
	x,y=map(int,list.pop())
	a.append((x+y)/2)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<double> V(N);
  for (size_t i = 0; i < N; i++) {
    cin >> V[i];
  }

  while (V.size() != 1) {
    sort(V.rbegin(), V.rend());
    int a = V.back();
    V.pop_back();
    int b = V.back();
    V.pop_back();
    V.push_back((double)(a + b) / (double)2.0);
  }

  printf("%lf\n", V[0]);

  return 0;
}

Submission status: Runtime Error

Solution code:
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long double> V(N);
  for (size_t i = 0; i < N; i++) {
    cin >> V[i];
  }

  while (V.size() != 1) {
    sort(V.rbegin(), V.rend());
    int a = V.back();
    V.pop_back();
    int b = V.back();
    V.pop_back();
    V.push_back((long double)(a + b) / (long double)2.0);
  }

  printf("%lf\n", V[0]);

  return 0;
}

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000)
n=int(input())
v=sorted(list(map(float,input().split())))
x=-1
y=-1
z=10000.0
while True:
    for i in range(n-1):
        if v[i+1]-v[i] < z:
            x=i+1
            y=i
            z=v[i+1]-v[i]
    v[y]=(v[x]+v[y])/2
    del(v[x])
    v=sorted(v)
    n=len(v)
    if n==1:
        print(v[0])
        break

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000)
n=int(input())
v=sorted(list(map(float,input().split())))
x=-1
y=-1
z=10000.0
while True:
    for i in range(n-1):
        if v[i+1]-v[i] < z:
            x=i+1
            y=i
            z=v[i+1]-v[i]
    v[y]=(v[x]+v[y])/2
    del(v[x])
    v=sorted(v)
    n=len(v)
    if n==1:
        print(v[0])
        break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
n=int(input())
lista=list(map(int,input().split()))
lista=sorted(lista)
for i in range(n-1):
    lista.append((lista[i]+lista[i+1])/2)
    lista.pop(i+1)
    lista.pop(i)
print(lista[0])

Submission status: Runtime Error

Solution code:
import numpy as np
n=int(input())
lista=list(map(int,input().split()))
lista=sorted(lista)
for i in range(n-1):
    lista.append((lista[i]+lista[i+1])/2)
    lista.pop(i+1)
    lista.pop(i)
print(lista)

Submission status: Runtime Error

Solution code:
N=int(input())
List=list(map(int,input().split()))
List.sort(reverse=True)
ans=0
for i in range(N-1):
  k = List[i]/(2**(i+1))
  ans += k
l = List[N]/(2**(N-1))
ans += l
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if i.count(i[0])==m:
    ans = i[0]
else:
    for j in range(n):
        if(j<n-1):
            if(i.count(i[0])>1):
                tmp = i[0]
            else:
                tmp = (i[j]+i[j+1])/2
            i.append(tmp)
            del i[0:2]
        i.sort()
    ans = (i[0]+i[1])/2

print(ans)

Submission status: Runtime Error

Solution code:
def execute(index, a_array):
    result_array = []
    for i in range(index):
        if i == index - 1:
            break
        for j in range(index - i):
            if j >= index - i:
                break
            result_array.append(((a_array[i] + a_array[i+j]) / 2, i, i+j))
            
    result_array.sort()
    result = result_array[0]
    
    new_array = []
    for index, a in enumerate(a_array):
        if index == result[1] or index == result[2]:
            continue
        new_array.append(a)
    new_array.append(result[0])
    
    if len(new_array) == 2:
        print((new_array[0] + new_array[1]) / 2)
    else:
        execute(len(new_array), new_array)
        

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

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

Submission status: Runtime Error

Solution code:
def execute(index, a_array):
    result_array = []
    for i in range(index):
        if i == index - 1:
            break
        for j in range(index - i):
            if j == index - i:
                break
            result_array.append(((a_array[i] + a_array[i+j]) / 2, i, i+j))
            
    result_array.sort()
    result = result_array[0]
    
    new_array = []
    for index, a in enumerate(a_array):
        if index == result[1] or index == result[2]:
            continue
        new_array.append(a)
    new_array.append(result[0])
    
    if len(new_array) == 2:
        print((new_array[0] + new_array[1]) / 2)
    else:
        execute(len(new_array), new_array)
        

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

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

Submission status: Runtime Error

Solution code:
def execute(index, a_array):
    result_array = []
    for i in range(index):
        if i == index - 1:
            break
        for j in range(index - i):
            if j == index - i - 1
            result_array.append(((a_array[i] + a_array[i+j]) / 2, i, i+j))
            
    result_array.sort()
    result = result_array[0]
    
    new_array = []
    for index, a in enumerate(a_array):
        if index == result[1] or index == result[2]:
            continue
        new_array.append(a)
    new_array.append(result[0])
    
    if len(new_array) == 2:
        print((new_array[0] + new_array[1]) / 2)
    else:
        execute(len(new_array), new_array)
        

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def execute(index, a_array):
    result_array = []
    for i in range(index):
        if i == index - 1:
            break
        for j in range(index - i):
            result_array.append(((a_array[i] + a_array[i+j]) / 2, i, i+j))
            
    result_array.sort()
    result = result_array[0]
    
    new_array = []
    for index, a in enumerate(a_array):
        if index == result[1] or index == result[2]:
            continue
        new_array.append(a)
    new_array.append(result[0])
    
    if len(new_array) == 2:
        print((new_array[0] + new_array[1]) / 2)
    else:
        execute(len(new_array), new_array)
        
import sys
a = []
for l in sys.stdin:
    a.append(l)

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

Submission status: Runtime Error

Solution code:
n,q = map(int, input().split())
a = []
for i in range(n-1):
    a.append((input()))

b = []
for j in range(q):
    b.append((input()))
    
aws = []
for k in range(n):
    aws.append(0)
    
def tree(t_num,point):
    aws[t_num - 1] +=  point
    for an in a:
        if t_num == int(an.split()[0]):
            tree(int(an.split()[1]),point)
for bn in b:
    t_num = int(bn.split()[0])
    point = int(bn.split()[1])
    tree(t_num,point)
    
aws_2 = []
for h in aws:
    str_h = str(h)
    aws_2.append(str_h)
print(" ".join(aws_2))

Submission status: Runtime Error

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

if i.count(i[0])==m:
    ans = i[0]
else:
    for j in range(n):
        if(j<n-1):
            if(i.count(i[0])>1):
                tmp = i[j]
            else:
                tmp = (i[j]+i[j+1])/2
            i.append(tmp)
            del i[0:2]
        i.sort()
    ans = (i[0]+i[1])/2

print(ans)

Submission status: Runtime Error

Solution code:
a = int(input())
b= [int(s) for s in input().split()]
b=sorted(b)

t = (b[0] + b[1])/2
for i in range(a-2):
  k = (t + b[i+2])/2
  t=k
  
print(k)

Submission status: Runtime Error

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
   else:
    pass
   num = num + 1
   except:
    break
 print(resa)
else:
 print((List[0] + List[1])/2)

Submission status: Runtime Error

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

if i.count(i[0])==m:
    ans = i[0]
else:
    for j in range(n):
        if(j<n-1):
            if(i.count(i[0])>=1):
                tmp = i[j]
            else:
                tmp = (i[j]+i[j+1])/2
            i.append(tmp)
            del i[0:2]
            i.sort()
        ans = (i[0]+i[1])/2

print(ans)

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

Solution code:
n = input()
nlist = []
for i in range(0,int(n)):
  x = input()
  nlist.append(float(x))
  
def avg(list):
    for i in range(0,int(n)-1):
        list.insert(0,float((list.pop(0) + list.pop(0)))/2)
    return list[0]    
        
print(avg(nlist))

Submission status: Runtime Error

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
        cook(N, V, alist, tmp, i)
        
cook(N, V, alist, tmp, i)

Submission status: Runtime Error

Solution code:
num = int(input())
lines = input().split(" ")
int_lines = [int(i) for i in lines]
int_lines.sort()
set_lines = set(int_lines)
count = 1
 
if num == 2:
  result = (int_lines[0] + int_lines[1]) / 2
  print(result)
else:
  itr = iter([int(j) for j in list(set_lines)])
  for j in itr:
    if count == 1:
        x = j
        count += 1
    elif count == 2:
        y = j
        count += 1
    else:
        x = (x + y) / 2
        y = j
        count += 1
  x = (x + y) / 2
    
  print(x)

Submission status: Runtime Error

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: Runtime Error

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()))
i2 = 1
while(i2<n):
    cur = find(s)
    #print(s)
    s = [i for i in s if i!=cur[1] and i!=cur[2]]
    s.append(cur[3])
    i2+=1
print(s[0])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

ma = []

for j in range(a):
    test = Lists.pop(0)
    for i in Lists:
        ma.append((i+test)/2)

ma2 = []
for j in ma:
    test = ma.pop(0)
    for i in ma:
        ma2.append((i+test)/2)

print (max(ma2))

Submission status: Runtime Error

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

if i.count(i[0])==m:
    ans = i[0]
else:
    for j in range(n):
        if(j<n-1):
            tmp = (i[j]+i[j+1])/2
            i.append(tmp)
            del i[0:2]
            i.sort()
        ans = (i[0]+i[1])/2

print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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(reverse(elements)):
            yi = len(elements) - yi - 1
            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: Runtime Error

Solution code:
num = int(input())
lines = input().split(" ")
int_lines = [int(i) for i in lines]
int_lines.sort()
set_lines = set(int_lines)
count = 1

if num == 2:
  result = (int_lines[0] + int_lines[1]) / 2
  print(result)
elif len(set_lines) == 1:
  print(set_lines[0])
elif len(set_lines) == 2:
  result = (set_lines[0] + set_lines[1]) / 2
  print(result)
else:
  itr = iter([int(j) for j in list(set_lines)])
  for j in itr:
    if count == 1:
        x = j
        count += 1
    elif count == 2:
        y = j
        count += 1
    else:
        x = (x + y) / 2
        y = j
        count += 1
  x = (x + y) / 2
    
  print(x)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for j in range(n):
    if(j<n-1):
        tmp = (i[j]+i[j+1])/2
        i.append(tmp)
        del i[0:2]
    i.sort()

ans = (i[0]+i[1])/2
print(ans)

Submission status: Runtime Error

Solution code:
a = int(input())
List=[int(i) for i in input().split()]
List.sort()
num = 0
ans = []
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)