Max's Anger Contest Series 1 P1 - Hunger Bar

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 0.1s
Java 0.2s
Python 0.2s
Memory limit: 256M

Author:
Problem type

Since Bob has been playing too much Minecraft, he has been viewing everything in terms of Minecraft, including whenever he is hungry.

He visualizes this hunger with a hunger bar with H hunger points. If he eats A apples, he will gain at most \min(H, A) hunger points since he only has at most H hunger points.

To further this visualization, Bob will lose 1 hunger point every second.

He cannot have negative hunger points.

Initially, he has 0 hunger points when he eats the apples.

After eating the A apples instantly, he will wait S seconds and wants to know the state of his hunger bar.

Can you help him determine his remaining hunger points?

Constraints

Subtask 1 [50%]

1 \le H, A, S \le 10^{5}

Subtask 2 [50%]

1 \le H, A, S \le 10^{9}

Input Specification

The first line will contain an integer, H, the number of hunger points he has available.

The second line will contain an integer, A, the number of apples he will eat.

The third line will contain an integer, S, the number of seconds he will wait.

Output Specification

Output the number of hunger points he will have after eating A apples and waiting S seconds.

Sample Input 1

5
3
1

Sample Output 1

2

Explanation for Sample 1

Bob eats the 3 apples and gains 3 hunger points. Then, he waits for 1 second and loses 1 hunger point, resulting in 2 hunger points.

Sample Input 2

10
20
5

Sample Output 2

5

Explanation for Sample 2

Bob eats the 20 apples and gains 10 hunger points since he only has 10 hunger slots. Then, he waits for 5 seconds and loses 5 hunger points, resulting in 5 hunger points.

Sample Input 3

1
50
1000

Sample Output 3

0

Explanation for Sample 3

Bob eats the 50 apples and gains 1 hunger point since he only has 1 hunger slot. Then, he waits 1\,000 seconds and loses 1 hunger point, resulting in 0 hunger points.


Comments


  • -1
    oscarhuang885  commented on Jan. 31, 2023, 7:12 p.m.

    I am wonder how hungry he is if he eats that much.


  • -1
    FionaH  commented on Jan. 29, 2023, 4:59 p.m.

    How long has Bob been playing Minecraft for?


  • 0
    gavin_chen  commented on Jan. 2, 2023, 4:25 p.m.

    blocc game :3