help in : http://codeforces.com/problemset/problem/118/D !

i have read the editorial but didn’t able to understand (: can anyone please help me!

//