由于m的范围只有1000,直接把数据存进哈希表,然后暴力循环
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 1010;
int n, m;
int st[N];
int main(void)
{
cin >> n >> m;
for(int i = 0; i < n; i++)
{
int t;
cin >> t;
if(t <= 1000) st[t]++;
}
for(int i = 0; i <= 1000; i++)
{
for(int j = 0; j <= 1000; j++)
{
if(i + j == m && st[i] && st[j])
{
if((i == j && st[i] >= 2) || i != j)
{
cout << i << ' ' << j << endl;
return 0;
}
}
}
}
puts("No Solution");
return 0;
}