Advertisement
Saleh127

CSES 1643

Apr 17th, 2021
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 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);cout.tie(0);
  9.  
  10.  
  11. ll n,ans=-1e12,i,j,k,l=0;
  12.  
  13. cin>>n;
  14.  
  15. while(n--)
  16. {
  17. cin>>k;
  18.  
  19. l+=k;
  20.  
  21. ans=max(ans,l);
  22.  
  23. l=max(0ll,l);
  24. }
  25. cout<<ans<<endl;
  26. return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement