You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 年之前
12345678910111213141516171819202122
  1. import sys
  2. from itertools import combinations
  3. text = sys.stdin.read()
  4. ns = [int(n) for n in text.splitlines()]
  5. for i, n in enumerate(ns):
  6. if i >= 25 and n not in {a + b for a, b in combinations(ns[:i][-25:], 2)}:
  7. ans1 = n
  8. print(ans1)
  9. i, j, s = 0, 0, ns[0]
  10. while s != ans1:
  11. if s < ans1:
  12. j += 1
  13. s += ns[j]
  14. elif s > ans1:
  15. s -= ns[i]
  16. i += 1
  17. ans2 = min(ns[i:j]) + max(ns[i:j])
  18. print(ans2)