27 lines
383 B
C++
27 lines
383 B
C++
#include<bits/stdc++.h>
|
|
using namespace std;
|
|
const int MAXN=100001;
|
|
int main() {
|
|
int a[MAXN];
|
|
int n,i,j,k;
|
|
int maxsum;
|
|
int temp;
|
|
cin>>n;
|
|
|
|
for(i=1; i<=n; i++)
|
|
cin>>a[i];
|
|
maxsum=a[1];
|
|
for(i=1; i<=n; i++)
|
|
for(j=1; j<=n; j++) {
|
|
temp=0;
|
|
for(k=i; k<=j; k++)
|
|
temp=temp+a[k];
|
|
if(maxsum<temp) maxsum=temp;
|
|
}
|
|
cout<<maxsum;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|