#C943. Minimum Operations to Transform Arrays

    ID: 53522 Type: Default 1000ms 256MiB

Minimum Operations to Transform Arrays

Minimum Operations to Transform Arrays

You are given two arrays, A and B, each containing N integers. In one operation, you can increment or decrement any element of array A by 1. Your task is to determine the minimum number of operations required to make array A identical to array B.

This can be achieved by computing the sum of the absolute differences between the corresponding elements of A and B. Mathematically, the number of operations is given by:

\( \text{Operations} = \sum_{i=1}^{N} |A_i - B_i| \)

Read the input from standard input and write the output to standard output.

inputFormat

The input begins with a single integer T, the number of test cases. For each test case, the first line contains an integer N denoting the size of the arrays. The second line contains N space-separated integers representing array A, and the third line contains N space-separated integers representing array B.

outputFormat

For each test case, output a single integer—the minimum number of operations required to transform array A into array B—on a new line.## sample

2
3
1 2 3
3 2 1
4
1 1 1 1
2 2 2 2
4

4

</p>