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.

14 line
308B

  1. import sys
  2. text = sys.stdin.read()
  3. pairs = [tuple(map(int, line.split('-'))) for line in text.splitlines()]
  4. valid, lo, hi = [], 0, 0
  5. for a, b in sorted(pairs):
  6. if a > hi:
  7. valid.extend(range(hi + 1, a))
  8. lo, hi = a, b
  9. lo, hi = min(lo, a), max(hi, b)
  10. print(valid[0])
  11. print(len(valid))