There was an error while loading. Please reload this page.
2 parents fb534c7 + e1683dd commit c94364aCopy full SHA for c94364a
JangWoojin/[5]백준/3649_로봇 프로젝트.cpp
@@ -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