Algorithm increase and maximum sub-sequence time limit: 1.0s memory limit: 512.0MBProblem description for a given integer sequence a of length n, the definition of its "subsequence" is: a non-empty contiguous element (integer). The task you want to accomplish is to find a subsequence in all possible sub-sequences, and the maximum of all the elements in that subsequence (as compared to all other subsequence sequences). The program requires you to output this maximum value. Input format the first line of the input file contains an integer n, the second line contains n integers, indicating a.
which
1 <= N <= 100000
-10000 <= A[i] <= 10000 output format output contains only an integer that represents the answer you have calculated. Sample input
53-2 3-5 4
Sample output
4
1#include <stdio.h>2 intMain () {3 intN;4 intmaxsum=0;5 intsum=0;6scanf"%d",&n);7 intA[n];8 for(intI=0; i<n;i++){9scanf"%d",&a[i]);Ten } One for(intI=0; i<n;i++){ Asum+=A[i]; - if(sum>maxsum) { -Maxsum =sum; the}Else{ -sum=0; - } - } +printf"%d", maxsum); - return 0; +}
C language · and maximum sub-sequences