Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- int n;
- cin >> n;
- int64_t mn = 0;
- int64_t mx = 0;
- int64_t cur = 0;
- for (int i = 0; i < n; i++) {
- int u;
- cin >> u;
- cur += u;
- mn = min(mn, cur);
- mx = max(mx, cur);
- }
- cout << mx - mn << '\n';
- }
- }
Add Comment
Please, Sign In to add comment