#K86867. Transforming Arrays

    ID: 36960 Type: Default 1000ms 256MiB

Transforming Arrays

Transforming Arrays

You are given two arrays, a and b, each of length n. Your task is to determine whether it is possible to transform array a into array b using a specific set of operations.

The allowed operation is to increase the value of any element in a to match the corresponding element in b. In doing so, two essential conditions must be satisfied for the transformation to be valid:

  • For every index \(i\) (1-indexed), \(a_i \le b_i\).
  • For every index \(i\) such that \(2 \le i \le n\), the incremental difference between consecutive elements of b must be at least as large as that of a. In other words, the following inequality must hold:
    \(b_i - b_{i-1} \ge a_i - a_{i-1}\).</p>

If both conditions are met, then the transformation is possible; otherwise, it is not.

Note: The indices in the mathematical expressions are assumed to start from 1. Adjust accordingly when implementing.

inputFormat

The input is read from standard input and has the following format:

  1. The first line contains a single integer \(T\), the number of test cases.
  2. For each test case, the first line contains an integer \(n\), the length of the arrays.
  3. The second line contains \(n\) space-separated integers, representing the array a.
  4. The third line contains \(n\) space-separated integers, representing the array b.

outputFormat

For each test case, output a single line containing either YES if it is possible to transform array a into array b under the given conditions, or NO otherwise.

## sample
1
4
1 2 3 4
2 3 3 5
NO

</p>