Untitled
unknown
c_cpp
9 months ago
382 B
2
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