You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
357 B
27 lines
357 B
#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;
|
|
}
|
|
|
|
|