#C8882. Maximum Pairs with Sum Constraint

    ID: 52913 Type: Default 1000ms 256MiB

Maximum Pairs with Sum Constraint

Maximum Pairs with Sum Constraint

You are given an integer n representing the number of elements, an integer D, and a list of n positive integers representing distances. Your task is to determine the maximum number of pairs that can be formed such that for each pair \( (a, b) \), the condition \( a + b \leq D \) holds. Each element from the list can be used at most once.

Note: The pair order does not matter and each valid pair contributes exactly one to the count of pairs.

inputFormat

The input is read from the standard input (stdin) and consists of two lines:

  • The first line contains two integers, n and D, separated by a space.
  • The second line contains n space-separated integers representing the distances.

outputFormat

Output a single integer to the standard output (stdout), which is the maximum number of pairs that can be formed such that the sum of the distances in each pair does not exceed \(D\).

## sample
5 10
2 3 5 8 1
2