Untitled
unknown
c_cpp
2 years ago
382 B
7
Indexable
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
int niza[n];
for(int i = 0; i < n; i++) {
cin >> niza[i];
}
long long res = -1e18;
for(int i = 0; i < n; i++) {
long long sum = 0;
for(int j = i; j < n; j++) {
sum += niza[j];
res = max(sum, res);
}
}
cout << res << endl;
return 0;
}
Editor is loading...
Leave a Comment