scientific_comp_projects/CODE/[python]kattis/medium/fluortanten.py

45 lines
805 B
Python
Raw Normal View History

2021-10-29 15:16:40 +02:00
n = int(input())
b = input()
b = b.split(' ')
position = []
for i in range(n):
position.append(i+1)
original_place = b.index('0')
del b[original_place]
size = len(b)
if size%2 ==0 :
half = int(size/2)
b1 = b[:half]
b2 = b[half:]
if size%2 !=0 :
size = len(b) + 1
half = int(size/2)
b1 = b[:half]
b2 = b[half:]
b1_total = 0
b2_total = 0
for i in range(half):
if 2*i < half:
b1_total = int(b1[i])*(i+1) + b1_total
b2_total = int(b2[i])*(2*i+1) + b2_total
print(b1_total)
print(b2_total)
print('--------------------')
answer = []
for i in range(n):
c = b.copy()
c.insert(i,0)
total = 0
print(c)
for j in range(len(position)):
total += int(c[j])*position[j]
answer.append(total)
print(total)
maxi = max(answer)