-->
当前位置:首页 > 题库

PROGRAMMING:Maximum subsequence sum problem

Luz5年前 (2021-05-10)题库371
Given a sequence of $$k $$integers {$$n}_ 1$$, $$N_ 2$$, ..., $$N_ K $$}, "continuous child column" is defined as {$$n_ i$$, $$N_{ i+1}$$, ..., $$N_ J $$}, where $$1 / Le I / Le J / Le K $$“ "Maximum sub column sum" is defined as the largest of the sum of all consecutive sub column elements. For example, given a sequence {- 2,11, - 4,13, - 5, - 2}, its continuous subsequence {11, - 4,13} has the largest sum of 20. Now you are required to write a program to calculate the maximum sub column sum of a given integer sequence.
The purpose of this paper is to test the performance of different algorithms under various data conditions. The characteristics of each group are as follows
-Data 1: it is equivalent to the sample and tests the basic correctness;
-Data 2: 10 < sup > 2 < / sup > random integers;
-Data 3: 10 < sup > 3 < / sup > random integers;
-Data 4: 10 < sup > 4 < / sup > random integers;
-Data 5: 10 < sup > 5 < / sup > random integers;
###Input format:
Enter the first line to give the positive integer $$k $$($$Le $$); Line 2 gives $$k $$integers separated by spaces.
###Output format:
Output the maximum sum of child columns in one row. If all integers in the sequence are negative, output 0.
###Input example:
```in
six
-2 11 -4 13 -5 -2
```
###Output example:
```out
twenty
```






answer:If there is no answer, please comment