QOJ.ac

QOJ

时间限制: 2 s 内存限制: 256 MB 总分: 100

#21203. רווחים

统计

הפרות פתחו עסק חדש, ו־Farmer John רוצה לראות כיצד הן מצליחות. העסק פועל כבר $N$ ($1 \leq N \leq 100{,}000$) ימים, ובכל יום $i$ הפרות רשמו את הרווח הנקי שלהן $P_i$ ($-1{,}000 \leq P_i \leq 1{,}000$).

Farmer John רוצה למצוא את הרווח הכולל הגדול ביותר שהפרות השיגו במהלך תקופה רציפה כלשהי. (שימו לב שאורך תקופה רציפה יכול לנוע מיום אחד עד $N$ ימים.) עזרו לו בכתיבת תוכנית שמחשבת את הסכום הגדול ביותר של רווחים רצופים.

קלט

קראו את הנתונים מהקלט הסטנדרטי.

  • שורה 1: מספר שלם אחד, $N$.
  • שורות $2..N+1$: שורה $i+1$ מכילה מספר שלם אחד, $P_i$.

פלט

כתבו את התוצאה לפלט הסטנדרטי.

  • שורה 1: מספר שלם אחד המציין את סכום הרווחים המרבי בתקופה רציפה כלשהי.

דוגמאות

קלט 1

7
-3
4
9
-2
-5
8
-3

פלט 1

14

הערה

הסכום המרבי מתקבל מסכימת המספר השני עד השישי (4, 9, -2, -5, 8), והתוצאה היא 14.

מחבר הבעיה: Neal Wu, 2007

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.