Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shops = input()
- price = input()
- a=price.split()
- p = list()
- n = 0
- while n < len(a) :
- p.append(int(a[n]))
- n = n+1
- p.sort()
- def khoj(list,coin):
- first = 0
- last = len(list)-1
- found = False
- while found is False:
- mid = int((first+last)//2)
- #print('length and mid ' ,len(list), mid)
- if coin >= list[len(list)-1] or coin < list[0] or list[mid] == coin or list[mid+1] > coin > list[mid]:
- found = True
- if len(list)==1 or list[mid] == coin or list[mid+1] > coin > list[mid] or list[mid-1] < coin < list[mid] :
- if len(list) == 1 :
- if coin >= list[0] :
- print('1')
- else :
- print('0')
- elif list[mid+1] > coin > list[mid]:
- print(mid+1)
- elif list[mid-1] < coin < list[mid] :
- print(mid)
- elif coin >= list[len(list)-1] :
- print(len(list))
- elif coin < list[0] :
- print('0')
- else :
- if coin > list[mid] :
- first = mid+1
- else :
- last = mid-1
- days = input()
- d = 0
- while d < int(days) :
- coins = input()
- khoj(p,int(coins))
- d = d+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement