Advertisement
nq1s788

бинарный поиск

Sep 4th, 2024
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. a = list(map(int, input().split()))
  2. x = int(input()) #индекс первого >= x
  3. l = -1
  4. r = len(a)
  5. while r - l > 1:
  6.     m = (r + l) // 2
  7.     if a[m] < x:
  8.         l = m
  9.     else:
  10.         r = m
  11. print(r)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement