1 // 688158 zhuli19901106 1352 Accepted 点击此处查看所有case的执行结果 4928KB 673B 1420MS
2 // 201401311706
3 #include <cstdio>
4 using namespace std;
5
6 const int MAXN = 1000005;
7 int a[MAXN];
8 int n;
9 int k;
10
11 int main()
12 {
13 int i;
14 bool suc;
15 int ll, rr;
16 int sum;
17
18 while (scanf("%d%d", &n, &k) == 2) {
19 for (i = 0; i < n; ++i) {
20 scanf("%d", &a[i]);
21 }
22 suc = false;
23 ll = 0;
24 rr = n - 1;
25 while (ll < rr) {
26 sum = a[ll] + a[rr];
27 if (sum < k) {
28 ++ll;
29 } else if (sum > k) {
30 --rr;
31 } else {
32 suc = true;
33 break;
34 }
35 }
36 if (suc) {
37 printf("%d %d\n", a[ll], a[rr]);
38 } else {
39 printf("-1 -1\n");
40 }
41 }
42
43 return 0;
44 }