Advertisement
Guest User

SPOJ

a guest
Oct 24th, 2016
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int a,b,c;
  6.     int e=0;
  7.     int d=0;
  8.     cin>>a;
  9.     for(b=0;b<a;b++)
  10.     {
  11.         cin>>c;
  12.          d=c+d;
  13.         if(d<=0)
  14.         {
  15.             d=0;
  16.         }
  17.         if(d>e)
  18.         {
  19.             e=d;
  20.         }
  21.     }
  22.         cout<<e<<" "<<d<<endl;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement