-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode1469B.cpp
More file actions
43 lines (31 loc) · 786 Bytes
/
Copy pathcode1469B.cpp
File metadata and controls
43 lines (31 loc) · 786 Bytes
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
43
/*
* Contest : Codeforces
* Problem : 1469B - Red and Blue
* Link : https://codeforces.com/contest/1469/problem/B
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fastio ios::sync_with_stdio(0); cin.tie(0);
int main() {
fastio
ios::sync_with_stdio(0);
cin.tie(0);
int tc, n, m; cin >> tc;
while (tc--) {
cin >> n;
vector<int> r(n), prefR(n + 1, 0);
for (int i = 0; i < n; i++) {
cin >> r[i];
prefR[i + 1] = prefR[i] + r[i];
}
cin >> m;
vector<int> b(m), prefB(m + 1, 0);
for (int i = 0; i < m; i++) {
cin >> b[i];
prefB[i + 1] = prefB[i] + b[i];
}
cout << *max_element(prefR.begin(), prefR.end()) + *max_element(prefB.begin(), prefB.end()) << endl;
}
return 0;
}