Advertisement
Rofyda_Elghadban1

Untitled

Sep 9th, 2023
1,214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.19 KB | None | 0 0
  1.  ll n,sum=0,maxi=INT_MIN;
  2.  cin>>n;
  3.  vector<ll>v(n);
  4.  cin(v);
  5.  for(ll i=0;i<v.size();i++){
  6.   if(v[i]>0){
  7.     sum+=v[i];
  8.   }else{
  9.     sum=0;
  10.   }
  11.   maxi=max(sum,maxi);
  12.  }cout<<maxi<<"\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement