SPOJ - Problem AGGRCOW - Aggressive cows

I have the same doubt. Did you find the answer?