以CF-1845D为例
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 3e5 + 10;
LL n;
LL a[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T;
cin >> T;
while (T -- )
{
cin >> n;
LL s = 0, maxs = 0, anss = 0, p = 0;
for (int i = 1; i <= n; i ++ )
{
cin >> a[i];
s += a[i];
maxs = max(maxs, s);
if (maxs - s > anss)
{
anss = maxs - s;
p = maxs;
}
}
cout << p << '\n';
}
}