Problem solving with Binary Search

Revision en2, by Kaleab_Asfaw, 2020-10-06 13:05:00

The problem is this.

I guess it is a common problem. I have tried it solving with binary search.

My Approach
Python Code

Difficulty — TLE

Help Needed — I know python is slow, but there are many peoples solving it with python. My question is how this code can be optimized (especially the valid function taking O(n*k) operations)?

I have seen the editorial, using other methods. But I am learning how to implement binary search, that is why I am trying this way.

Thanks for taking the time for reading this!

UPDATE: Accepted

Tags #binary search, #tle

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Kaleab_Asfaw 2020-10-06 13:05:00 78
en1 English Kaleab_Asfaw 2020-10-06 11:36:46 1909 Initial revision (published)