#C6171. Minimum Operations to Transform Array

    ID: 49902 Type: Default 1000ms 256MiB

Minimum Operations to Transform Array

Minimum Operations to Transform Array

You are given two arrays of integers, a and b, each of length n. In one operation, you can increment or decrement any element of array a by 1. Your task is to find the minimum number of operations required to transform a into b. In other words, you need to calculate:

$$\text{result} = \sum_{i=1}^{n} \left|a_i - b_i\right| $$

where \(a_i\) and \(b_i\) are the elements of the arrays a and b respectively. Each test case should be solved independently.

inputFormat

The first line of input contains a single integer T denoting the number of test cases. Each test case is described as follows:

  • The first line contains an integer n representing the number of elements in the arrays.
  • The second line contains n space-separated integers representing the array a.
  • The third line contains n space-separated integers representing the array b.

All input is read from stdin.

outputFormat

For each test case, output a single line containing the minimum number of operations required to convert array a to array b. The output should be written to stdout.

## sample
5
3
1 2 3
2 3 4
4
1 1 1 1
2 3 4 5
3
5 5 5
5 5 5
3
10 20 30
15 25 35
1
0
1000
3

10 0 15 1000

</p>