1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| #include <bits/stdc++.h> #define ouo ios_base::sync_with_stdio(false), cin.tie(0) #define ll long long #define db double using namespace std;
int main() { int t; cin >> t; while (t--) { int n; cin >> n; int data[n]; int mx = -INT_MAX; int sum = 0; for (int i = 0; i < n; i++) { cin >> data[i]; sum += data[i]; mx = max(mx, sum); if (sum < 0) sum = 0; } cout << mx << "\n"; } return 0; }
|