Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- const int INF = 1e9 + 10;
- const int MAXN = 1e6 + 10;
- int a[MAXN], b[MAXN];
- void solve(){
- int n;
- cin >> n;
- for (int i = 1; i <= n; i++){
- cin >> a[i];
- }
- for (int i = 1; i <= n; i++){
- cin >> b[i];
- }
- bool was_positive = 0, was_negative = 0;
- for (int i = 1; i <= n; i++){
- if (a[i] != b[i]){
- if (b[i] > 0 && was_positive == 0){
- cout << "NO\n";
- return;
- }
- if (b[i] < 0 && was_negative == 0){
- cout << "NO\n";
- return;
- }
- if (b[i] == 0 && a[i] > 0 && was_negative == 0){
- cout << "NO\n";
- return;
- }
- if (b[i] == 0 && a[i] < 0 && was_positive == 0){
- cout << "NO\n";
- return;
- }
- }
- if (a[i] > 0){
- was_positive = 1;
- }
- if (a[i] < 0){
- was_negative = 1;
- }
- }
- cout << "YES\n";
- }
- int main()
- {
- int t = 1;
- cin >> t;
- while(t--){
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment