Problem Link: https://codeforces.me/contest/1417/problem/C
My solution: https://codeforces.me/contest/1417/submission/131124634
My solution is very similar (or almost same) to the editorial's solution: https://codeforces.me/blog/entry/83036 The only difference I noticed is that I'm using cin/cout instead of scanf/printf and I'm using vectors instead of arrays. Also, I'm using #define int long long.