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