CCC '20 J1 - Dog Treats


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 512M

Problem type
Allowed languages
C++, Python
Canadian Computing Competition: 2025 Stage 1, Senior #1

Peter the painter just finished painting two rectangular paintings and would like to display both on a rectangular wall which has the smallest perimeter possible. The first painting has a base of length \(A\) units and a height of length \(B\) units. The second painting has a base of length \(X\) units and a height of length \(Y\) units.

Peter has a few conditions on how to arrange his paintings on the rectangular wall. The first condition is that the paintings must be upright, meaning that the bases of the paintings are parallel to the floor. The second condition is that he would like to display both paintings in full, meaning that they cannot overlap each other. Please help determine the rectangular wall of minimum perimeter such that the paintings can be displayed without violating his conditions.

Input Specification

The one line of input will consist of four space-separated positive integers, \(A\) , \(B\) , \(X\) , \(Y\) \((1 \leq A, B, X, Y \leq 10^8)\) .

The following table shows how the available \(15\) marks are distributed:

where \(S\) is the number of small treats, \(M\) is the number of medium treats and \(L\) is the number of large treats.

If Barley's happiness score is \(10\) or greater then he is happy. Otherwise, he is sad. Determine whether Barley is happy or sad at the end of the day.

Input Specification

There are three lines of input. Each line contains a non-negative integer less than \(10\) . The first line contains the number of small treats, \(S\) , the second line contains the number of medium treats, \(M\) , and the third line contains the number of large treats, \(L\) , that Barley receives in a day.

Output Specification

If Barley's happiness score is \(10\) or greater, output happy . Otherwise, output sad .

Sample Input 1

3
1
0

Output for Sample Input 1

sad

Explanation of Output for Sample Input 1

Barley's happiness score is \(1 \times 3 + 2 \times 1 + 3 \times 0 = 5\) , so he will be sad.

Sample Input 2

3
2
1

Output for Sample Input 2

happy

Explanation of Output for Sample Input 2

Barley's happiness score is \(1 \times 3 + 2 \times 2 + 3 \times 1 = 10\) , so he will be happy.

Marks

Comments

There are no comments at the moment.