#C3222. Partition Sequence into Pairs
Partition Sequence into Pairs
Partition Sequence into Pairs
Given a sequence of integers, determine whether it is possible to partition the sequence into pairs such that the sum of the integers in each pair equals a given target value \( k \). Note that the sequence must contain an even number of elements. For a valid partition, every pair \( (a, b) \) must satisfy \( a + b = k \).
Your program should read from standard input and output the result to standard output.
inputFormat
The first line contains two integers \( n \) and \( k \) separated by a space, where \( n \) is the number of elements in the sequence and \( k \) is the target sum for each pair.
The second line contains \( n \) integers representing the sequence, separated by spaces.
outputFormat
Output a single line containing possible
if it is possible to partition the sequence into pairs such that every pair sums to \( k \); otherwise, output impossible
.
4 7
1 6 2 5
possible