-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathb.cpp
44 lines (41 loc) · 1014 Bytes
/
b.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
43
44
#include <bits/stdc++.h>
#define endl '\n'
#define eat cin
#define moo cout
#define int long long
using namespace std;
int T, N, a[50000], b[50000], d[50000];
int32_t main(){
eat.tie(0) -> sync_with_stdio(0);
eat >> T;
while(T--){
eat >> N;
for(int i = 0; i < N; i++) eat >> a[i];
for(int i = 0; i < N; i++) eat >> b[i];
for(int i = 0; i < N; i++){
d[i] = a[i] - b[i];
}
bool good = true;
int est = 2e9;
for(int i = 0; i < N; i++){
if(d[i] < 0){
good = false;
break;
}
if(b[i] == 0) continue;
if(est == 2e9){
est = d[i];
}
if(est != d[i]){
good = false;
break;
}
}
for(int i = 0; i < N; i++){
if(b[i] == 0){
if(d[i] > est) good = false;
}
}
moo << (good ? "YeS" : "no") << endl;
}
}