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. Or maybe , if someone can give an idea , as to how they think while applying binary seacrh.