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