Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. a = int(input())
  2. n = []
  3. for i in range(a):
  4. n.append(int(input()))
  5. maxl = 10**9 * 2
  6. minl = 0
  7. while maxl - minl > 1:
  8. mid = (maxl + minl) // 2
  9. ans = 0
  10. for i in n:
  11. if i > mid:
  12. ans += i - mid
  13. if mid >= ans:
  14. maxl = mid
  15. else:
  16. minl = mid
  17. print(maxl)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement