Codejam 2020 Problem B

solution of problem B with explanation
https://youtu.be/jtGs3Vo3XI4

Check out detailed solutions.