QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 64 MB 満点: 50

#13708. Tarifa

統計

Pero 与他的互联网服务提供商协商了一个非常划算的流量套餐。该运营商允许 Pero 每月最多使用 $X$ MB 的流量来上网。每个月未用完的流量都会结转到下个月,并且仍然可以使用。当然,Pero 只能使用他实际拥有的流量。

如果我们知道 Pero 在使用该套餐的前 $N$ 个月中每个月使用了多少 MB 的流量,请确定 Pero 在使用该套餐的第 $N + 1$ 个月将有多少可用流量。

输入格式

输入的第一行包含整数 $X$($1 \le X \le 100$)。

输入的第二行包含整数 $N$($1 \le N \le 100$)。

接下来的 $N$ 行,每行包含一个整数 $P_i$($0 \le P_i \le 10\,000$),表示在使用该套餐的前 $N$ 个月中,每个月所消耗的流量(MB)。数据保证 $P_i$ 的值不会超过 Pero 实际拥有的流量。

输出格式

输出的唯一一行应包含题目要求的答案。

样例

输入样例 1

10
3
4
6
2

输出样例 1

28

输入样例 2

10
3
10
2
12

输出样例 2

16

输入样例 3

15
3
15
10
20

输出样例 3

15

说明

第一个样例的解释:

在第一个月,在总共 $10$ MB 的流量中,Pero 消耗了 $4$ MB,并将 $6$ MB 结转到下个月。在第二个月,在总共 $16$ ($10+6$) MB 的流量中,Pero 消耗了 $6$ MB,并将 $10$ MB 结转。在第三个月,在总共 $20$ ($10+10$) MB 的流量中,Pero 消耗了 $2$ MB,并将 $18$ MB 结转。在第四个月,他总共有 $28$ MB 的流量可以使用。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.