-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patholliePS-161.cpp
42 lines (42 loc) · 897 Bytes
/
olliePS-161.cpp
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define MAX 1000000000
#define flash() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
flash();
ll t;
cin >> t;
for(ll i = 1 ; i <= t ; i++)
{
ll n;
cin >> n;
ll total = 0;
vector<ll> v;
for(ll j = 0 ; j < n ; j++)
{
ll x;
cin >> x;
total += x;
v.push_back(x);
}
if(n == 1)
{
cout << total << endl;
}
else
{
ll ps = 0 , mini = total;
for(ll j = 0 ; j < n ; j++)
{
ps += v[j];
ll maxi = max(ps , total - ps);
mini = min(mini , maxi);
}
cout << mini << endl;
}
}
return 0;
}