-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1253A.cpp
38 lines (31 loc) · 781 Bytes
/
1253A.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
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
int a[n], b[n];
for (int i = 0; i < n; i++)
scanf("%d", &a[i]);
int dif[n];
bool ka = 1;
int gaps = 0, ptkan = -1;
for (int i = 0; i < n; i++) {
scanf("%d", &b[i]);
dif[i] = b[i]-a[i];
if (dif[i] < 0)
ka = 0;
else if (dif[i] != ptkan) {
ptkan = dif[i];
gaps++;
}
}
if (dif[0] == 0) gaps--;
if (dif[n-1] == 0) gaps--;
if (gaps > 1) ka = 0;
(ka) ? printf("YES\n") : printf("NO\n");
}
}