ZOJ Problem Set - 3525
On the morning of December 18 in Gensokyo, Izayoi Sakuya went to Remilia Scarlet's bedroom to wake she up. Strangely, there was no one in the bedroom. Sakuya used her special ability of time freezing and searched every nooks. To her surprise, Remilia was disappeared!
It was really a terrible event for the Scarlet Devil Mansion. Actually, not only Remilia, many other girls in Gensokyo were also disappeared! The famous reporter, Shameimaru Aya, got the news soon and started to investigate this event. She found the girls were abducted by a strange small alien creature.
The creature thinks every girl has a potential ability that can be quantized as an entropy S. In addition, every girl has three attributes: Love, Courage and Righteousness. We use three variables B W H to indicate them.
To some incomprehensible reasons, the creature wants to gather entropy as low as possible by abduct girls in Gensokyo. Due to the limitation of the creature itself, the girls it abducted must satisfy the following constraints:
Since the event was happened, Shameimaru Aya need your help to calculate the minimal entropy that the creature can gather. By the way, if there is no way to gather a negative quantity of entropy, the creature will have no interest to our girls.
There are multiple test cases. For each test case:
The first line contains an integer N (1 <= N <= 1000) indicates the number of girls in Gensokyo. Then followed by N lines, each line contains four integers Bi Wi Hi Si and each absolute value of those will not exceed 1000. The last line contains 3 integers LB LW LH and each of them is a non-negative integer which will not exceed 2000.
For each test case, output the minimal entropy that the creature can gather. If there is no way to gather a negative quantity of entropy, output "Error 404, mahou shoujo not found!".
3 2 5 3 -4 3 5 0 -2 1 4 2 -7 2 0 4 1 4 0 4 1 1 1 1
-7 Error 404, mahou shoujo not found!
Author: JIANG, Kai