Guest User

Untitled

a guest
Jan 11th, 2023
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     ios_base::sync_with_stdio(false);
  7.     cin.tie(0);
  8.     int t;
  9.     cin >> t;
  10.     while (t--) {
  11.         int n;
  12.         cin >> n;
  13.         int64_t mn = 0;
  14.         int64_t mx = 0;
  15.         int64_t cur = 0;
  16.         for (int i = 0; i < n; i++) {
  17.             int u;
  18.             cin >> u;
  19.             cur += u;
  20.             mn = min(mn, cur);
  21.             mx = max(mx, cur);
  22.         }
  23.         cout << mx - mn << '\n';
  24.     }
  25. }
  26.  
Add Comment
Please, Sign In to add comment