Thornhill Computer Club 2023 - September Contest - Problem 2
In the futuristic school of Zornhill Secondary School (ZSS), a magical classroom exists with a special property. This magical classroom has the ability to change its length and width by casting spells in order to accommodate any class size. The classroom can be divided into a grid of 1 x 1 meter squares which can each fit a single desk for each student. However, to increase personal space between students, desks cannot be within grid space away from each other in all directions (including diagonals). Mr. Z, a teacher of ZSS, has decided to use the classroom for his upcoming course but does not know how big the classroom must be to fit his students.
To solve this, he decides to cast spells to increase or decrease the width or length of the classroom.
Given that the classroom starts with an initial width of and initial length of , can you determine whether the new classroom can fit all students>?
Input Specifications
The first line of input will contain three integers, and , the width and length of the classroom () and , the number of students in Mr. Z's class ().
The next line will contain a single integer representing the number of spells Mr. Z cast ().
The next lines will contain two integers, and representing the change in width and the change in length of the spell ().
Due to limitations with magic, if spells are casted to decrease the size of the classroom below 1 x 1, the classroom would continue to shrink until it reaches a size of 1 x 1.
Output Specifications
Output yes
or no
depending on whether or not the new class is large enough to fit Mr. Z's students.
Sample Input 1
3 3 10
5
-2 1
6 -2
-3 5
5 -3
-1 1
Sample Output 1
yes
Explanation for Sample Output 1
After 5
spells, the final classroom size will be 8 x 5
. In a class of this size, 10 desks for 10 students can fit inside this classroom in the following configuration.
Sample Input 2
10 8 1000
3
23 5
12 36
9 23
Sample Output 2
no
Explanation for Sample Output 2
The final room size would be 54 x 72
spaces. It is impossible to fit 1000 desks into a room of this size without having all desks at least one grid space away from each other.
Sample Input 3
10 10 5
8
95 34
12 1
-96 45
34 21
-23 -87
-64 -51
17 35
-15 -31
Sample Output 3
yes
Comments