#K7111. Drone Battery Pairing
Drone Battery Pairing
Drone Battery Pairing
You are given a number of drones and a required battery capacity for a storage compartment. Each drone has a battery with a certain capacity. Your task is to select unique pairs of drones such that the sum of their battery capacities is exactly equal to the required capacity. Each drone can only be used once. When a pair consists of two identical battery capacities, there must be at least two drones with that capacity available.
The answer pairs should be output in lexicographical order (i.e. for a pair (a, b), it must hold that a ≤ b, and the list of pairs is sorted). If no valid pair exists, do not output anything.
inputFormat
The input is given via standard input (stdin) and has the following format:
The first line contains two integers n and b, where n is the number of drones and b is the required battery capacity. The second line contains n integers, representing the battery capacities of the drones.
outputFormat
Print each valid pair in a separate line. Each line should contain two integers separated by a space, representing the battery capacities of the drones forming the valid pair. The pairs should be unique and sorted in lexicographical order. If no valid pair exists, print nothing.## sample
5 10
2 4 6 8 10
2 8
4 6
</p>