Skip to content

Commit c94364a

Browse files
authored
Merge pull request #523 from jeeneee/woojin
로봇 프로젝트
2 parents fb534c7 + e1683dd commit c94364a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <algorithm>
4+
using namespace std;
5+
6+
int main() {
7+
ios::sync_with_stdio(0);
8+
cin.tie(0);
9+
10+
int x, n;
11+
while (cin >> x) {
12+
cin >> n;
13+
x *= 1e7;
14+
vector<int> a(n);
15+
for (int i = 0; i < n; i++) cin >> a[i];
16+
17+
sort(a.begin(), a.end());
18+
19+
int i = 0;
20+
int j = n - 1;
21+
while (i < j) {
22+
int sum = a[i] + a[j];
23+
if (sum == x)
24+
break;
25+
else if (sum < x)
26+
i++;
27+
else if (sum > x)
28+
j--;
29+
}
30+
31+
if (i >= j)
32+
cout << "danger" << endl;
33+
else
34+
cout << "yes " << a[i] << ' ' << a[j] << endl;
35+
}
36+
37+
return 0;
38+
}

0 commit comments

Comments
 (0)