-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumOfThreeVal.cpp
More file actions
33 lines (33 loc) · 834 Bytes
/
Copy pathSumOfThreeVal.cpp
File metadata and controls
33 lines (33 loc) · 834 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
#include "bits/stdc++.h"
// #include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,x;
cin>>n>>x;
multimap<int,int> m;
for(int i=0;i<n;i++){
int num;
cin>>num;
m.insert(make_pair(num,i+1));
}
for(auto c:m){
int val=c.first;
int idx=c.second;
for(auto d:m){
int val1=d.first;
int idx1=d.second;
if(idx==idx1) continue;
auto it=m.find(x-(val+val1));
while(it!=m.end()&&it->first==x-(val+val1)){
if(it->second!=idx&&it->second!=idx1){
cout<<idx<<" "<<idx1<<" "<<it->second<<endl;
return 0;
}
it++;
}
}
}
cout<<"IMPOSSIBLE"<<endl;
}