I have tried this problem very much but failed to solve this. I have looked on many codes but failed to understand. Since this problem has no editorial so I can't forward anymore.
Please anyone give me some explanation on this problem. Link: http://codeforces.com/contest/257/problem/C
Thanks.