Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ll n,sum=0,maxi=INT_MIN;
- cin>>n;
- vector<ll>v(n);
- cin(v);
- for(ll i=0;i<v.size();i++){
- if(v[i]>0){
- sum+=v[i];
- }else{
- sum=0;
- }
- maxi=max(sum,maxi);
- }cout<<maxi<<"\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement