-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy patha.cc
More file actions
37 lines (34 loc) · 676 Bytes
/
a.cc
File metadata and controls
37 lines (34 loc) · 676 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
// https://codeforces.com/contest/1253/problem/A
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t, n, x;
cin >> t;
while (t--) {
cin >> n;
vi a(n);
for (int i = 0; i < n; i++) cin >> a[i];
int d = 0, c = 0;
bool ok = 1;
for (int i = 0; i < n; i++) {
cin >> x;
int d2 = x - a[i];
if (d2 < 0) ok = 0;
if (d == d2) continue;
if (d) {
if (d2) ok = 0;
d = 0;
} else {
if (c) ok = 0;
d = d2;
c++;
}
}
if (ok) cout << "YES\n";
else cout << "NO\n";
}
}