Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. jugadores = input().split()
  2. jugadores = [int(i) for i in jugadores]
  3.  
  4. def busqueda_Binaria(a,inicio,fin,x):
  5. if (inicio==fin):
  6. if (x>=a[inicio]):
  7. return inicio
  8. else:
  9. return (inicio-1)
  10. else:
  11. mitad=(inicio+fin)//2
  12. if x==a[mitad]:
  13. return mitad
  14. else:
  15. if x>a[mitad]:
  16. return busqueda_Binaria(a, mitad+1, fin, x)
  17. else:
  18. return busqueda_Binaria(a, inicio, mitad-1, x)
  19.  
  20. indice=0
  21. for i in range(0,m):
  22. if jugadores[i]>=enemigos[n-1]:
  23. print(enemigos[n-2], "X")
  24. else:
  25. if jugadores[i]<=enemigos[0]:
  26. print("X",enemigos[0])
  27. else:
  28. indice=busqueda_Binaria(enemigos,0,n-1,jugadores[i])
  29. print(enemigos[indice], enemigos[indice+1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement