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 + 1;
- }
- sort(niza, niza + n);
- int i = 0;
- int j = n - 1;
- while(i < j){
- int sum = niza[i].first + niza[j].first;
- if(sum == x){
- cout << niza[i].second << " " << niza[j].second;
- return 0;
- }
- else if(sum < x){
- i++;
- }
- else{
- j--;
- }
- }
- cout << "IMPOSSIBLE";
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment