#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N, M;
vector<int>coins;
int search(int first,int low, int high) {
int mid = (low + high) / 2;
if (low > high) return -1;
if (coins[mid] == M - first) {
return mid;
}
else if (coins[mid] > M - first) {
high = mid - 1;
return search(first, low, high);
}
else {
low = mid + 1;
return search(first, low, high);
}
}
int main() {
cin >> N >> M;
for (int i = 1; i <= N; i++) {
int temp; cin >> temp;
coins.push_back(temp);
}
sort(coins.begin(), coins.end());
for (int i = 1; i < N; i++) {
int second = search(coins[i - 1], i, N - 1);
if (second != -1) {
cout << coins[i-1] << " " << coins[second];
return 0;
}
}
cout << "No Solution";
return 0;
}
|