How to approach the problem

https://codeforces.com/contest/1452/problem/B

can you please explain me how to approach the problem, i watch editorial on you tube but didnt understand.
please explain me how to approach the problem

HEY @shivamgoel150
Please share the editorial u refered to .

I found his explanation good enough : https://www.youtube.com/watch?v=xqKwV0MqX9o
If u dont understand something in his explanation of this question then let me know :slight_smile:

Hey @shivamgoel150
Just saw ur message ,please continue all the chat here

So what exactly u didn’t understood ?
Everything was quite clear

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.