WOSS Dual Olympiad 2022 J1: Holiday Gifting

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 256M

Problem type

It is Christmas time, and you are buying gifts for your friends! While planning, you have shortlisted the following gifts: A candy canes at $1 each, B coffee mugs at $4 each, and C ugly sweaters at $7 each. However, being a high school student, you have a budget to keep in mind. You can spend at most N dollars.

You now need to check whether or not your planned gifts fall within your budget.


0 \le N \le 500

0 \le A, B, C \le 50

Input Specification

The first line consists of a single integer, N, representing the maximum amount you can spend.

The second line consists of three space-separated integers, A, B, and C, representing the number of purchased candy canes, coffee mugs and ugly sweaters, respectively.

Output Specification

If your buying plan is within the budget, output Time to go shopping!.

If you cannot afford all the gifts, output You cannot afford them all..

Sample Input 1

3 5 2

Sample Output 1

Time to go shopping!

Explanation of Sample 1

In this case, you purchased 3 candy canes, 5 coffee mugs and 2 ugly sweaters. Hence, the total cost of the gifts is $37, which is within your budget of $45.

Sample Input 2

6 2 5

Sample Output 2

You cannot afford them all.

Explanation of Sample 2

In this case, you purchased 6 candy canes, 2 coffee mugs and 5 ugly sweaters. Hence, the total cost of the gifts is $49, which is above your budget of $33.


There are no comments at the moment.