You are on page 1of 1

CSEC-ASTU Competitive Programming Division, Division-1 2nd

semester Contest-1 March 9, 2022

Two Sum
Input file: standard input
Output file: standard output
Time limit: 1 second

Given an integer X and an array a of N distinct integers, design an efficient algorithm to determine if
there exists two distinct integers a and b in the array such that a + b = X.

Input
The first line consists of two integers separated by space N and X where( 1 <= N <= 106 ) the
number of elements in the array. and X where(1 <= X <= 106 ) the target value. The second line
contains the elements of the array separated by space.

Output
The two values in ascending order separated by space. If there are not any values in the array that
add up to give the target value, output “impossible” with out quotation.If thre are multiple
answers output the one which has the least integer in it.

Sample Input 1 Sample Output 1


5 14 59
89745

Sample Input 1 Sample Output 1


5 67 impossible
89745

Page 1 of 1

You might also like