-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
54 lines (54 loc) · 1006 Bytes
/
Copy pathtest.cpp
File metadata and controls
54 lines (54 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* @Description: test.cpp
* @Author: Xu Jiaming
* @Date: 2022-04-22 16:10:39
* @LastEditTime: 2022-05-07 20:10:19
* @LastEditors:
* @FilePath: test.cpp
*/
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[100000+5];
int binary_search(int l,int r,int dst)
{
int mid = (l+r)/2;
if(a[mid] == dst)
{
return mid;
}
else
{
if(l >= r)
{
return -1;
}
else
{
if(dst > a[mid]) return binary_search(mid+1,r,dst);
if(dst < a[mid]) return binary_search(l,mid-1,dst);
}
}
}
int main()
{
scanf("%d",&n);
scanf("%d",&m);
for(int i = 0; i < n; i++) scanf("%d",&a[i]);
sort(a,a+n);
bool pd = true;
for(int i = 0; i < n; i++)
{
int t = binary_search(0,n-1,m-a[i]);
if(t != -1)
{
pd = false;
printf("%d %d",a[i],a[t]);
break;
}
}
if(pd)
{
printf("No Solution");
}
}