fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define int long long
  5. #define yes cout << "YES\n";
  6. #define no cout << "NO\n";
  7.  
  8.  
  9. void FastIO(){
  10. ios_base::sync_with_stdio(false);
  11. cin.tie(nullptr);
  12. cout.tie(nullptr);
  13. }
  14. ///Sum of two values
  15. void solve(){
  16. int n,x; cin >> n >> x;
  17.  
  18. vector<int>vec(n+1);
  19. map<int,pair<int,int>> freq;
  20.  
  21. for(int i = 1; i <= n; i++){
  22. cin >> vec[i];
  23. }
  24.  
  25. int l,r; bool flg = false;
  26. for(int i = 1; i <= n; i++){
  27. if(freq[x-vec[i]].second > 0){
  28. flg = true;
  29. l = freq[x-vec[i]].first;
  30. r = i;
  31. break;
  32. }
  33.  
  34. freq[vec[i]].first = i;
  35. freq[vec[i]].second++;
  36. }
  37. if(flg){
  38. cout << l << " " << r;
  39. }
  40. else{
  41. cout << "IMPOSSIBLE";
  42. }
  43. }
  44.  
  45. signed main(){
  46. FastIO();
  47.  
  48. int t = 1;
  49. //cin >> t;
  50.  
  51. while(t--){
  52. solve();
  53. }
  54. return 0;
  55. }
Success #stdin #stdout 0.01s 5276KB
stdin
4 8
2 7 5 1
stdout
2 4