I read the main idea behind binary search and how it is implemented , but am never able to apply it using certain modifications . I tried solving http://www.spoj.com/problems/AGGRCOW/ , but have not been able to. Can someone please cite some useful resources , from where I can get an idea about how to modify binary search algorithm as and when the need arises.