Advertisement
DatProgrammer

P20262

Oct 22nd, 2015
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6.   int n;
  7.   while (cin >> n) {
  8.    
  9.     int a, total, beg, end;
  10.     total = beg = end = 0;
  11.    
  12.     for (int i = 1; i <= n; i++) {
  13.      
  14.       cin >> a;
  15.       total += a; //total = total + a
  16.      
  17.       if (total >= beg) beg = total;
  18.       else if (total <= end) end = total;  
  19.     }
  20.    
  21.     cout << beg << " " << (total - end) << endl;
  22.    
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement