#include <stdio.h>
int main(int argc, char *argv[]) {
int n, m;
int face[501] = {0};
scanf("%d %d", &n, &m);
int i;
for (i = 0; i < n; i++) {
int tmp;
scanf("%d", &tmp);
face[tmp]++;
}
for (i = (m > 500 ? 500 : m - 1); i >= 1; i--) {
if (face[i] > 0 && face[m - i] > 0 && i != m - i) {
printf("%d %d\n", m - i, i);
return 0;
} else if (face[i] >= 2 && i == m - i) {
printf("%d %d\n", m - i, i);
return 0;
}
}
printf("No Solution\n");
return 0;
}
【PAT甲级】1048. Find Coins (25)
最新推荐文章于 2021-02-09 21:24:45 发布