A1338 | [COCI-2016_2017-contest1]#5 Tarifa
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
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 doesn’t 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.
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.
输入格式
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 ≤ 10 000), 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.
The second line of input contains the integer N (1 ≤ N ≤ 100).
Each of the following N lines contains an integer Pi(0 ≤ Pi ≤ 10 000), 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.
输出格式
The first and only line of output must contain the required value from the task.
输入输出样例
输入 #1
10 3 4 6 2
输出 #1
28
输入 #2
10 3 10 2 12
输出 #2
16
输入 #3
15 3 15 10 20
输出 #3
15
In the first month, out of 10 total megabytes, Pero has spent 4 and transferred 6 into the next month. In
the second month, out of 16 (10+6) total megabytes, Pero has spent 6 and transferred 10. In the third
month, out of 20 (10+10) total megabytes, Pero has spent 2 and transferred 18. In the fourth month, he
had a total of 28 megabytes to spend.
the second month, out of 16 (10+6) total megabytes, Pero has spent 6 and transferred 10. In the third
month, out of 20 (10+10) total megabytes, Pero has spent 2 and transferred 18. In the fourth month, he
had a total of 28 megabytes to spend.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted