#C2718. Count Distinct Pairs with a Given Sum
Count Distinct Pairs with a Given Sum
Count Distinct Pairs with a Given Sum
Given a list of integers, possibly containing duplicates, your task is to count the number of distinct pairs (a, b) such that:
$a + b = target\_sum$
Note that a pair is considered distinct based on the two values regardless of their order. For example, the pairs (1, 5) and (5, 1) are the same and should be counted only once.
Example: For the list [1, 5, 7, 1, 5] and target sum 6, the only distinct pair is (1, 5).
inputFormat
The input consists of two lines:
- The first line contains two integers n and target_sum, where n is the number of elements in the list.
- The second line contains n integers separated by spaces representing the list.
outputFormat
Output a single integer representing the count of distinct pairs whose sum is equal to target_sum.
## sample5 6
1 5 7 1 5
1