Kaynağa Gözat

2020/9

master
Roderic Day 4 yıl önce
ebeveyn
işleme
cd6a007d7b
1 değiştirilmiş dosya ile 22 ekleme ve 0 silme
  1. +22
    -0
      y2020/p09.py

+ 22
- 0
y2020/p09.py Dosyayı Görüntüle

@@ -0,0 +1,22 @@
import sys
from itertools import combinations


text = sys.stdin.read()
ns = [int(n) for n in text.splitlines()]
for i, n in enumerate(ns):
if i >= 25 and n not in {a + b for a, b in combinations(ns[:i][-25:], 2)}:
ans1 = n
print(ans1)


i, j, s = 0, 0, ns[0]
while s != ans1:
if s < ans1:
j += 1
s += ns[j]
elif s > ans1:
s -= ns[i]
i += 1
ans2 = min(ns[i:j]) + max(ns[i:j])
print(ans2)

Yükleniyor…
İptal
Kaydet