'Driveaway' problem from csacademy

I am not able to solve the problem nor understand the editorial.

Link - https://csacademy.com/contest/archive/task/driveaway

@yuvi2701 I’ve forwarded your doubt to mentor since I was unable to come up with approach matching constraints.