-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
43 lines (33 loc) · 795 Bytes
/
main.cpp
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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline void solve() {
int n, x;
cin >> n >> x;
vector<pair<int, int>> nums(n);
for (int i = 0; i < n; ++i) {
int v;
cin >> v;
nums[i] = {v, i + 1};
}
sort(nums.begin(), nums.end());
for (int i = 0; i < n; ++i) {
int l = i + 1;
int r = n - 1;
while (l < r) {
int v = nums[i].first + nums[l].first + nums[r].first;
if (v == x) {
cout << nums[i].second << ' ' << nums[l].second << ' ' << nums[r].second;
return;
}
v < x ? ++l : --r;
}
}
cout << "IMPOSSIBLE";
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}