CCC '20 J1 - Dog Treats

View as PDF

Submit solution

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

Problem type
Canadian Computing Competition: 2020 Stage 1, Junior #1

Barley the dog loves treats. At the end of the day, he is either happy or sad depending on the number and size of treats he receives throughout the day. The treats come in three sizes: small, medium, and large. His happiness score can be measured using the following formula:

\displaystyle 1 \times S + 2 \times M + 3 \times L

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.


Comments


  • 0
    dakshaisacoder  commented on Oct. 24, 2024, 12:49 a.m.

    finished it in 5 mins. Not too bad!


  • 0
    Weifeng_Wang  commented on Feb. 21, 2024, 2:21 a.m.

    this must be easy if you ever learned math


  • -24
    mariuspuzhouli  commented on May 10, 2022, 12:37 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • -4
      savirsingh  commented on July 29, 2022, 3:40 p.m.

      Most people passed first try, look at the stats graph.


  • 5
    iiGam_r  commented on Feb. 18, 2021, 10:42 p.m.

    Hint's for anyone coming across this comment:

    • Look closely at the formula, what can you do with this knowledge?
    • 2nd, if you already know how to make variable have an inputed value, then all you need is 1 more step!(Hint: something to do with ifs and else ifs. Also something to do with the formula.)
    • And last, but not least, REMEMBER SPELLING! Spelling counts in these cases, test cases to be exact.

    Hope you find these hints helpful! Upvote if yes!


  • 6
    Serendipity_skys  commented on Feb. 16, 2021, 3:28 a.m.

    CAPITALIZATION COUNTS ON THIS QUESTION! Don't make the same mistake I did and capitalize the first letters of the output...


  • -3
    BadAccount  commented on July 2, 2020, 4:40 p.m.

    Why does this problem have a 512 MB memory limit?


    • 18
      maxcruickshanks  commented on July 2, 2020, 8:01 p.m. edited

      The memory limit reflects the limit from the CCC, but the time limit is smaller because the DMOJ judge is faster.