EISUBARRAY - Subarray with the largest sum
Xem dạng PDF
Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given an array of integers ~A~. A subarray of array ~A~ is an array of zero or more consecutive elements in ~A~.
Given array ~A~, find the largest possible absolute sum of a non-empty subarray of ~A~.
Input
- The first line is an integer ~n~ (~n \leq 10^6~)
- The second line is the ~n~ integers of array ~A~ ~(A_i \le 10^9)~.
Output
- The largest possible sum
Example Input 1
7
-1 2 4 -1 6 -10 1
Example Output 1
11
Bình luận