AcWing 1532. 找硬币
原题链接
简单
作者:
daydayup_6
,
2021-01-19 22:12:17
,
所有人可见
,
阅读 314
#include <iostream>
#include <cstring>
#include <algorithm>
#include <unordered_set>
using namespace std;
const int INF = 10000;
int main()
{
int m, n;
cin >> m >> n;
unordered_set<int> hash;
int v1 = INF, v2;
for(int i = 0; i < m; i++)
{
int a, b;
cin >> a;
b = n - a;
if(hash.count(b))
{
hash.insert(a);
if(a > b) swap(a,b);
if(a < v1) v1 = a, v2 = b;
}
else hash.insert(a);
}
if(v1 == INF) cout << "No Solution";
else cout << v1 << ' ' << v2;
}