#K41962. Almost Equal Arrays

    ID: 26982 Type: Default 1000ms 256MiB

Almost Equal Arrays

Almost Equal Arrays

Problem Description

Given two arrays a and b of length \( n \) and an integer \( k \), determine whether the arrays are almost equal. Two arrays are considered almost equal if the total number of positions where their corresponding elements differ, i.e. \( \sum_{i=1}^{n} \mathbf{1}(a_i \neq b_i) \), is less than or equal to \( k \).

For each test case, print YES if the arrays are almost equal, or NO otherwise.

inputFormat

The first line of the input contains an integer \( t \), the number of test cases.

For each test case:

  • The first line contains two integers \( n \) and \( k \): the number of elements in the arrays and the maximum allowed number of differences respectively.
  • The second line contains \( n \) space-separated integers representing the first array.
  • The third line contains \( n \) space-separated integers representing the second array.

outputFormat

For each test case, output a single line containing YES if the arrays are almost equal, or NO otherwise.

## sample
3
3 1
1 2 3
1 2 4
3 2
1 2 3
4 5 6
5 3
1 2 3 4 5
1 2 4 4 5
YES

NO YES

</p>