Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- vector <int> m(n);
- int min_el=0;
- int max_sum=0;
- cin>>m[0];
- max_sum=m[0];
- if (min_el>m[0]) min_el=m[0];
- for(int i=1; i<n; i++)
- {
- cin>>m[i];
- m[i]+=m[i-1];
- if (max_sum<m[i]-min_el) max_sum=m[i]-min_el;
- if (min_el>m[i]) min_el=m[i];
- }
- cout << max_sum << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement