QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 2048 MB مجموع النقاط: 100

#2909. 透支

الإحصائيات

如果你尝试从账户中提取的金额超过了当前余额,银行通常会收取透支费用。给定一系列存款和取款操作(假设每笔存款和取款都会立即反映在你的余额中),请确定你需要的最少(非负)起始余额,以确保在整个操作序列过程中不会被收取任何透支费用。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 1,000$),表示交易次数。

接下来的 $n$ 行,每行包含一个整数 $t$ ($-10^6 \le t \le 10^6, t \neq 0$)。这些是按发生顺序排列的交易。正数表示存款,负数表示取款。没有两笔交易是同时发生的。

输出格式

输出一个非负整数,表示为了避免任何透支费用,你账户中必须具备的最小起始余额。

样例

输入 1

3
3
-5
3

输出 1

2

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.