mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2024-11-28 06:13:43 +03:00
33 lines
509 B
Python
33 lines
509 B
Python
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)
|