Saleh127

UVA 10684

Dec 10th, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11.  
  12. ll n;
  13. while(cin>>n && n)
  14. {
  15. ll a[n+5],b=0,c=0,i,j,k,l;
  16. for(i=0; i<n; i++)
  17. {
  18. cin>>a[i];
  19. }
  20. for(i=0; i<n; i++)
  21. {
  22.  
  23. b+=a[i];
  24.  
  25. c=max(c,b);
  26.  
  27. if(b<0) b=0;
  28. }
  29. if(c<=0) cout<<"Losing streak."<<endl;
  30. else cout<<"The maximum winning streak is "<<c<<"."<<endl;
  31.  
  32. }
  33.  
  34. return 0;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment