Files
kattis/Tarifa.py
2022-05-13 21:37:10 +02:00

34 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
Pero has negotiated a Very Good data plan with his internet provider. The
provider will let Pero use up X megabytes to surf the internet per month. Each
megabyte that he doesnt spend in that month gets transferred to the next month
and can still be spent. Of course, Pero can only spend the megabytes he
actually has.
If we know how much megabytes Pero has spent in each of the first N months of
using the plan, determine how many megabytes Pero will have available in the
N+1 month of using the plan.
Input
The first line of input contains the integer X (1≤X≤100). The second line of
input contains the integer N (1≤N≤100). Each of the following N lines contains
an integer Pi (0≤Pi≤10000), the number of megabytes spent in each of the first
N months of using the plan. Numbers Pi will be such that Pero will never use
more megabytes than he actually has.
Output
The first and only line of output must contain the required value from the
task.
"""
import sys
x = int(sys.stdin.readline())
n = int(sys.stdin.readline())
p = (n + 1) * x
for _ in range(n):
p -= int(sys.stdin.readline())
print(p)