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.

3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
123456789101112
  1. ns = [int(n) for n in open(0).read().split(',')]
  2. lo, *_, hi = sorted(ns)
  3. def mono_min(g):
  4. y = next(g)
  5. for x in g:
  6. if x > y: return y
  7. y = x
  8. print(mono_min(sum(abs(n - m) for m in ns) for n in range(lo, hi)))
  9. range_sum = lambda n: int(n * (n + 1) / 2)
  10. print(mono_min(sum(range_sum(abs(n - m)) for m in ns) for n in range(lo, hi)))