mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2024-11-22 11:56:33 +03:00
33 lines
509 B
Python
Vendored
33 lines
509 B
Python
Vendored
with open("26.txt") as f:
|
|
data = list(map(int, f.read().splitlines()[1:]))
|
|
|
|
nums = sorted(data)
|
|
s = 0
|
|
il = 0
|
|
|
|
for i, el in enumerate(nums):
|
|
n = i + 1
|
|
if len(nums) - il == i:
|
|
break
|
|
if n % 3 == 0:
|
|
il += 1
|
|
else:
|
|
s += el
|
|
|
|
print(s)
|
|
|
|
nums = sorted(data, reverse=True)
|
|
s = 0
|
|
il = 0
|
|
|
|
for i, el in enumerate(nums):
|
|
n = i + 1
|
|
if len(nums) - il == i:
|
|
break
|
|
if n % 3 == 0:
|
|
il += 1
|
|
else:
|
|
s += el
|
|
|
|
print(s)
|