DMPG '19 S1 - Candy Shop Tycoon

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Mimi has recently found a very fun game - Candy Shop Tycoon! In this game, you are the owner of a candy store enterprise, each of which will produce some amount of candy at a constant rate.

Mimi, being a new player, only owns candy shops. The first shop produces candies per hour, the second candies per hour, and the third candies per hour.

She is trying to complete a quest where she must produce exactly candies in the next hours. To accomplish this, once an hour, she can tell any candy shop(s) to cease all production, or to restart production. Can you help Mimi clear this quest?

Input Specification

The first line of input will contain 3 space-separated integers: , , and .
The second and final line of input will contain a single integer: .

Output Specification

Output QUEST CLEARED if this is possible, and TRY AGAIN otherwise.

Sample Input 1

2 3 5
1000

Sample Output 1

QUEST CLEARED

Explanation for Sample Output 1

If we let all three shops produce candy, then we will produce candies per hour, and running this for hours gives you candies.

Sample Input 2

1 10 20
3089

Sample Output 2

QUEST CLEARED

Explanation for Sample Output 2

If we let all three shops produce candy, then we will produce candies per hour, and running this for hours gives you candies.
Shutting off the first and second shops for hour gives you total candies.

Sample Input 3

2 4 6
7

Sample Output 3

TRY AGAIN