P25496 [AtCoder] [ABC031B] Exercise Management
入门
题目描述

Problem Description

Takahashi is the mascot character of AtCoder Inc.

To maintain his charm as a mascot character, Takahashi is required to do moderate exercise. Takahashi must exercise for at least $ L $ minutes and at most $ H $ minutes per week.

However, Aoki has not seen Takahashi exercising recently. Concerned about Takahashi's exercise status, Aoki decided to create a program that calculates whether Takahashi's past $ N $ weeks of exercise time are within the limits, and if not, how many more minutes at least he needed to exercise.

Input Format

The input is given from the standard input in the following format:

$ L $ $ H $ $ N $ $ A_1 $ $ A_2 $ : $ A_N $

  • The first line contains two integers $ L $, $H\ (1≦L≦H≦10^4)$ separated by a space. This indicates that Takahashi must exercise between $ L $ and $ H $ minutes per week.
  • The second line contains an integer $N\ (1≦N≦50)$. This indicates that Aoki is investigating the exercise time for $ N $ weeks.
  • The next $ N $ lines contain integers representing Takahashi's exercise status. The $i\ (1≦i≦N)$th line contains an integer $A_i\ (0≦A_i≦10^4)$. This indicates that Takahashi exercised for $ A_i $ minutes in the $ i $th week before the current week.

Output Format

The output consists of $ N $ lines. The $i\ (1≦i≦N)$th line should contain $ -1 $ if Takahashi exercised more than the required minutes in the $ i $th week before the current week, otherwise, it should contain the minimum additional exercise time in minutes needed for that week.

Ensure to include a newline at the end of the output.

Sample Input and Output

Sample Input #1

300 400
3
240
350
480

Sample Output #1

60
0
-1

Sample Input #2

50 80
5
10000
50
81
80
0

Sample Output #2

-1
0
-1
0
50

Notes/Hints

Sample Explanation 1

Aoki is investigating for $ 3 $ weeks.
- In the week before last, Takahashi exercised for $ 240 $ minutes, which is less than the lower limit of $ 300 $ minutes. Takahashi needs to exercise an additional $ 60 $ minutes, so output $ 60 $ on the first line.
- Two weeks ago, Takahashi exercised for $ 350 $ minutes, which is within the exercise time limits. Therefore, output $ 0 $ on the second line.
- Three weeks ago, Takahashi exercised for $ 480 $ minutes, which exceeds the upper limit of $ 400 $ minutes, indicating too much exercise. Therefore, output $ -1 $ on the third line.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
300 400 3 240 350 480
样例输出
60 0 -1