#K94687. Count Distinct Absolute Values
Count Distinct Absolute Values
Count Distinct Absolute Values
You are given an integer \(N\) and an array \(A\) of \(N\) integers. Your task is to compute the number of distinct absolute values in the array.
The absolute value of an integer \(x\) is represented as \(|x|\). For example, \(|-3| = 3\) and \(|3| = 3\). The problem asks you to count how many unique values exist when each element is transformed by the absolute value operation.
Input Example: For \(N = 5\) and \(A = [-1, -1, 0, 1, -2]\), the distinct absolute values are \(\{0, 1, 2\}\), so the output should be 3
.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains an integer \(N\) indicating the number of elements in the array.
- The second line contains \(N\) space-separated integers which represent the elements of the array \(A\).
outputFormat
Output a single integer to standard output (stdout) representing the number of distinct absolute values in the array \(A\).
## sample5
-1 -1 0 1 -2
3