-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDEPCHEF.cpp
More file actions
42 lines (38 loc) · 944 Bytes
/
DEPCHEF.cpp
File metadata and controls
42 lines (38 loc) · 944 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
#include <bits/stdc++.h>
int attack[101] = {0};
int defence[101] = {0};
int getNetAttack(int i, int n) {
if (i == 0)
return attack[1] + attack[n-1];
if (i == n-1)
return attack[i-1] + attack[0];
return attack[i-1] + attack[i+1];
}
int main(void) {
int T;
std::cin >> T;
while(T--) {
int N;
std::cin >> N;
for (int i = 0; i < N; i++) {
int temp;
std::cin >> temp;
attack[i] = temp;
}
for (int i = 0; i < N; i++) {
int temp;
std::cin >> temp;
defence[i] = temp;
}
// int index = -1;
int max_def = -1;
for (int i=0; i < N; i++) {
if (defence[i] > getNetAttack(i, N)) {
if (max_def < defence[i]) {
max_def = defence[i];
}
}
}
std::cout << max_def << std::endl;
}
}