#C3686. Zero Sum Disjoint Pairs
Zero Sum Disjoint Pairs
Zero Sum Disjoint Pairs
Given an array of integers, find the maximum number of disjoint pairs \( (i,j) \) with \( i < j \) such that \( a_i + a_j = 0 \). In other words, each element in the array can be used in at most one pair. For example, for the array [-1, 1, 2, -2]
, the answer is 2.
Note: A pair is defined as two indices \( i \) and \( j \) with \( i < j \), and once an element is used in a pair, it cannot be reused.
The relationship can be mathematically stated as: find the maximum \( k \) such that there exists \( k \) pairs \( (i, j) \) with \( i < j \) and \( a_i + a_j = 0 \).
inputFormat
Input is read from standard input (stdin).
outputFormat
Output should be written to standard output (stdout). Each test case output should be on a new line.
## sample2
4
-1 1 2 -2
5
3 -3 0 1 -1
2
2
</p>