Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- int n;
- ll x;
- cin >> n >> x;
- pair<ll, int> niza[n];
- for(int i = 0; i < n; i++) {
- cin >> niza[i].first;
- niza[i].second = i;
- }
- sort(niza, niza + n);
- for(int k = 0; k < n; k++) {
- int i = k + 1, j = n - 1;
- while(i < j) {
- if(niza[i].first + niza[j].first + niza[k].first == x) {
- cout << niza[k].second + 1 << " " << niza[i].second + 1 << " " << niza[j].second + 1 << endl;
- return 0;
- }
- if(niza[i].first + niza[j].first + niza[k].first < x) {
- i++;
- }
- else {
- j--;
- }
- }
- }
- cout << "IMPOSSIBLE" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement