#C2432. Count Matching Positions in Two Arrays
Count Matching Positions in Two Arrays
Count Matching Positions in Two Arrays
In this problem, you are given two arrays A and B, each containing N integers. Your task is to count the number of positions i (0-based indexing) where the i-th element in array A is equal to the i-th element in array B. This is a straightforward problem that requires you to iterate over the arrays and compare elements at the same index.
Formally, given two sequences (A = [a_0, a_1, \ldots, a_{N-1}]) and (B = [b_0, b_1, \ldots, b_{N-1}]), you need to compute the value: [ \text{count} = \sum_{i=0}^{N-1} \mathbf{1}(a_i = b_i), ] where (\mathbf{1}(\text{condition})) is 1 if the condition holds, and 0 otherwise.
Make sure your program reads input from standard input (stdin) and writes the answer to standard output (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 representing the array (A). The third line contains (N) space-separated integers representing the array (B).
outputFormat
Output a single integer which is the count of positions where the two arrays have the same element.## sample
5
1 2 3 4 5
5 4 3 2 1
1