-
Notifications
You must be signed in to change notification settings - Fork 1
/
anya.cpp
56 lines (42 loc) · 988 Bytes
/
anya.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
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, x;
cin >> n >> x;
vector <int> v;
vector <pair <int, int>> p;
for(int i = 0;i < n;i++){
int a;
cin >> a;
v.push_back(a);
p.push_back({a, i});
}
sort(v.begin(), v.end());
sort(p.begin(), p.end());
for(int k = 0;k < n;k++){
int l = 0, r = n-1;
int sum = x - v[k];
while(l < r){
if(l == k){
l++;
continue;
}
if(r == k){
r--;
continue;
}
if(v[l] + v[r] == sum){
cout << p[l].second+1 << " " << p[r].second+1 << " " << p[k].second+1 << "\n";
return 0;
}
if(v[l] + v[r] > sum){
r--;
continue;
}
l++;
continue;
}
}
cout << "IMPOSSIBLE" << "\n";
return 0;
}