Doors Breaking and Repairing

CodeForces - 1102C