Link to the problem:- http://mirror.codeforces.com/problemset/problem/437/B
I read the editorial where it says we have to use greedy approach by iterating from limit to 1. I don't understand why this approach works here.Iterating from 1 to limit doesn't work here.
Can someone help me in proving why greedy approach(iterating from limit to 1) works here ?
Thanks.