fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n,l,r,k;
  6. pair<int,int>a[200009];
  7. int main(){
  8. cin>>n>>k;
  9. for(int i=1;i<=n;i++){
  10. cin>>a[i].first;
  11. a[i].second=i;
  12. }
  13. sort(a+1,a+n+1);
  14. l=1; r=n;
  15. while(l<r){
  16. if(a[l].first+a[r].first<k){
  17. l++;
  18. }
  19. else if(a[l].first+a[r].first>k){
  20. r--;
  21. }
  22. else {
  23. break;
  24. }
  25. }
  26. if(l==r) cout<<"IMPOSSIBLE"<<endl;
  27. else cout<<a[l].second<<" "<<a[r].second<<endl;
  28. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
0 0