Sunday, March 25, 2012

SPOJ: Aggressive Cows

Its been quite a long time since i got inspiration to solve SPOJ problems. Then i hear about this problem and how binary search could create problems in it. So deciding to give it a go (c’mon how tough can binary search be??) i start coding it up. About 20 wrong attempts on my PC and TLE exceeded 5 times on SPOJ, finally realised i was doing binary search on the quantity with a smaller bounds and normal iteration through the one with larger bounds. .!!! One wrong submission later (submitted it in ADA instead of c++ :P ) finally got ACC. .

The problem can be found here. .
http://www.spoj.pl/problems/AGGRCOW/
Cheers

3 comments:

  1. hi
    i am getting WA in AGGRCOW
    used binary search concept
    is there any special test case ???

    ReplyDelete
    Replies
    1. Not as far as i know. . Once i figured out the right quantity to binary search on, i got ACC. .

      Delete
    2. Actually i had made the binary search to find the max. partition size posiible.
      Now i am making partitions to divide the distance among partitions.
      How to handle the cases where the some of the partitions will be left blank ???

      Delete