fork download
  1. #include <bits/stdc++.h>
  2. #define endl '\n'
  3. #define yes cout<<"YES\n"
  4. #define no cout<<"NO\n"
  5. using namespace std;
  6. void fast(){
  7. ios_base::sync_with_stdio(NULL);
  8. cin.tie(0);cout.tie(0);
  9. }
  10. bool isbit(int n,int x){
  11. if((n&(1<<x)))return 1;
  12. else return 0;
  13. }
  14. multiset<int>stl,str;
  15. int main(){
  16. fast();
  17. int t=1;
  18. //cin>>t;
  19. while(t--){
  20. int n,a,x;
  21. cin>>n>>x;
  22. vector<pair<int,int>>v;
  23. for(int i=0;i<n;i++){
  24. cin>>a;
  25. v.push_back({a,i+1});
  26. }
  27. sort(v.begin(),v.end());
  28. int r=n-1,l=0,sum=0;
  29. while(l<r){
  30. sum=v[l].first+v[r].first;
  31. if(sum==x){
  32. cout<<v[l].second<<" "<<v[r].second;
  33. return 0;
  34. }else if(sum>x)r--;
  35. else l++;
  36. }
  37. cout<<"IMPOSSIBLE";
  38. }
  39. }
  40.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
IMPOSSIBLE