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