Editorial for TCCC '23 Sept P2 - The Magical Classroom
Submitting an official solution before solving the problem yourself is a bannable offence.
Authors:
Let and represent the width and length of the classroom.
To solve the problem, simply process each spell and keep track of the current width and length of the room by adding to the width and length.
Since the first index corresponds to the change in width, simply add this value to the current width. The same can be done for the length of the classroom, corresponding to the second index within the input.
Notice, the width or height classroom cannot be reduced to a size lower than 1 x 1. To account for this, simply set and after processing each spell, where represents a function that returns the largest value given two inputs. This prevents the width or length of the class from every falling below 1.
The last step is to simply calculate the maximum number of desks within the final classroom and compare it with the number of desks required. This can be calculated with the formula , where represents the largest integer equal to or smaller than .
Comments