LCC '21 Contest 5 J2 - Bottle Refilling

View as PDF

Submit solution

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

Author:
Problem type

Justin is using his new water bottle, which has a strange trick, it can automatically refill itself! The bottle is N liters in volume and originally full, and Justin will drink a_i liters from it on day i. The bottle will refill itself at the end of the day to N liters if the amount of water left is less than or equal to K.

Can you figure out on which days the bottle refills itself? Or, if the amount Justin drinks is more than what is left in the bottle, output Impossible.

Input Specifications

The first line will contain integers N, M (1 \leq N, M \leq 100) and K (1 \leq K \leq N), the volume of the bottle, the number of days, and the volume at where the bottle will refill itself, respectively.

The next M lines will contain 1 integer a_i (1 \leq a_i \leq N), representing how many liters Justin drank on day i.

Output Specifications

If there are any days where Justin drinks more liters than what is left in the bottle, output Impossible.

Otherwise, output the days where the bottle will refill itself.

Sample Input 1

10 5 2
6
2
3
4
3

Sample Output 1

2
5

Sample Explanation 1

On day 2, Justin drank a total of 8 liters from his water bottle, leaving 2 liters left so the bottle will refill. After that, Justin drank a total of 10 liters, so the bottle will refill again on day 5.

Sample Input 2

9 4 3
4
1
5
2

Sample Output 2

Impossible

Comments

There are no comments at the moment.