Hi all,
I have difficulty on a problem on codeforces http://mirror.codeforces.com/problemset/problem/691/D
my submission is : http://mirror.codeforces.com/contest/691/submission/19308291
I think my idea is right, I used dsu to group several numbers and sort numbers inside the group. But I don't know why I am still wrong answer. The idea is simple, but what's wrong? Anyone please help me, thanks:D