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