-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path631B.cpp
More file actions
49 lines (46 loc) · 962 Bytes
/
Copy path631B.cpp
File metadata and controls
49 lines (46 loc) · 962 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
43
44
45
46
47
48
49
#include <bits/stdc++.h>
using namespace std;
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]);
}
for (int i = 0; i < n; i++)
{
scanf("%d", &b[i]);
}
bool one = false, minus = false,no = false;
for (int i = 0; i < n; i++)
{
if(a[i] < b[i] && !one){
no = true;
break;
}
else if(a[i] > b[i] && !minus){
no = true;
break;
}
else if(a[i]==-1){
minus = true;
}
else if(a[i]==1){
one = true;
}
}
if(no){
printf("NO\n");
}
else
{
printf("YES\n");
}
}
}