Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- //freopen("text.txt", "r", stdin);
- int n, a[103] = {}, sp[103] = {};
- cin >> n;//min 1 nr > 0
- assert(n <= 100);
- for (int i = 1; i <= n; i++) {
- cin >> a[i];
- sp[i] = sp[i - 1] + a[i];
- assert(abs(a[i]) < 100000);
- }
- int mini = 0, ans = -1e9;
- for (int i = 1; i <= n; i++) {
- ans = max(ans, sp[i] - mini);
- mini = min(mini, sp[i]);
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement