How to optimize my solution for this problem?

Правка en1, от 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



Теги #binary search, #codechef, #help, #optimization

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский LemonMonster 2021-04-30 12:14:02 7722 Initial revision (published)