[Solution] Array Decrements Codeforces Solution
Kristina has two arrays and , each containing non-negative integers. She can perform the following operation on array any number of times:
- apply a decrement to each non-zero element of the array, that is, replace the value of each element such that with the value (). If was , its value does not change.
Determine whether Kristina can get an array from an array in some number of operations (probably zero). In other words, can she make after some number of operations for each ?
Solution Click Below:- CLICK HERE
For example, let , and . In this case, she can apply the operation twice:
- after the first application of the operation she gets ;
- after the second use of the operation she gets .
Thus, in two operations, she can get an array from an array .
The first line of the input contains an integer () —the number of test cases in the test.
The descriptions of the test cases follow.
The first line of each test case contains a single integer ().
The second line of each test case contains exactly non-negative integers ().
The third line of each test case contains exactly non-negative integers ().
It is guaranteed that the sum of values over all test cases in the test does not exceed .
For each test case, output on a separate line:
- YES, if by doing some number of operations it is possible to get an array from an array ;
- NO otherwise.
You can output YES and NO in any case (for example, strings yEs, yes, Yes and YES will be recognized as a positive response).
No comments:
Post a Comment