is there any greedy solution possible for this problem
https://mirror.codeforces.com/problemset/problem/1223/C
CF Edu Round 173 Solution Discussion