-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNikoCards.cpp
More file actions
37 lines (32 loc) · 854 Bytes
/
NikoCards.cpp
File metadata and controls
37 lines (32 loc) · 854 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
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<long long> a(n);
vector<long long> b(n);
for (long long& i : a) cin >> i;
for (long long& i : b) cin >> i;
long long maxK = 0;
long long minK = 0;
for (int i = 0; i < n; i++) {
long long redMax = maxK - a[i];
long long redMin = minK - a[i];
long long blueMax = b[i] - minK;
long long blueMin = b[i] - maxK;
maxK = max(redMax, blueMax);
minK = min(redMin, blueMin);
}
cout << maxK << endl;
}
return 0;
}