#C1241. Minimum Operations to Make Arrays Identical
Minimum Operations to Make Arrays Identical
Minimum Operations to Make Arrays Identical
You are given two arrays of integers, each containing n elements. In one operation, you can increment or decrement an element in an array by 1. Your task is to determine the minimum number of operations required to make the two arrays identical. More formally, if the arrays are represented as \(A = [A_1, A_2, \dots, A_n]\) and \(B = [B_1, B_2, \dots, B_n]\), you are required to compute:
\(\sum_{i=1}^{n} |A_i - B_i|\)
This sum represents the minimum number of operations needed to transform array A into array B (or vice versa), where each operation changes one element by 1. Make sure to read the input from stdin and output the result to stdout.
inputFormat
The first line contains an integer \(n\) representing the number of elements in each array. The second line contains \(n\) space-separated integers for the first array \(A\). The third line contains \(n\) space-separated integers for the second array \(B\).
outputFormat
Output a single integer: the minimum number of operations required to make the two arrays identical.
## sample3
1 2 3
3 2 1
4