NOI Contest Archive

Archive / 2024 / Qualifier Round

reductor

Medium · NOI 2024 Qualifier Round

You’re given an array \(a\) of length \(n\), array \(b\) of length \(n\) and a reduction parameter \(r\).

Your target is to reduce all values in the array such that the array only contains non-positive values.

In a single step, you can negate \(r\) from every element in \(a\). After applying this negation, \(r\) will be reduced by \(k\).

\(k\) is the lowest value in \(b\), where the corresponding element in \(a\) is positive.

There are \(t\) testcases. For each case, If it’s possible to achive the goal output “YES”, otherwise “NO”.

Input Format

Input:

Output Format

Output:

Constraints

Constraints:

Sample Input 0

1
6 7
18 5 13 9 10 1
2 7 2 1 2 6

Sample Output 0

YES