How to optimize my solution for this problem?

Revision en1, by LemonMonster, 2021-04-30 12:14:02

Hello Everybody , Recently I was learning Binary Search and tried to to solve thsi problem using it. -- Link to the problem. My solution is like the one given in step 2 of binary search in codeforces edu by pashka
I have a good function to check if the people are enough to reach the desired place. in the beginning the l is 0 and the r is 1. then I continue multiplying r by 2 unless i reach a solution (r is definitely true ) then I binary search for the answer. But my program gives time limit exceeded.

My full solution



Only the good function



The mian function



Tags #binary search, #codechef, #help, #optimization

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English LemonMonster 2021-04-30 12:14:02 7722 Initial revision (published)