#include <stdio.h>
#include <iostream>
#pragma warning(disable:4996);
using namespace std;
const int maxn = 100010;
int coin[maxn];
int n, m;
int main()
{
scanf("%d %d", &n, &m);
fill(coin, coin + maxn, 0);
for (int i = 0; i < n; i++)
{
int k;
scanf("%d", &k);
coin[k] += 1;
}
//判断能否有两个硬币组成
for (int i = 0; i <= m/2; i++)
{
if (coin[i] != 0 && coin[m - i] != 0)
{
if (i == m - i && coin[i] < 2)
{
continue;
}
printf("%d %d", i, m - i);
return 0;
}
}
printf("No Solution");
return 0;
}
1048. Find Coins (25)-PAT甲级真题(Hash散列)
最新推荐文章于 2024-08-20 20:01:22 发布