fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. int n,s,x; cin >> n >> s;
  6. map<int,int> m;
  7. vector<int> v(n);
  8. for(int i=1;i<=n;i++) cin >> v[i-1];
  9. for(int i=1;i<=n;i++){
  10. int need = s - v[i-1];
  11. if(m.find(need) != m.end()){
  12. cout << m[need] << " " << i;
  13. return 0;
  14. }
  15. m[v[i-1]] = i;
  16. }
  17. cout << "IMPOSSIBLE";
  18. return 0;
  19. }
Success #stdin #stdout 0s 5284KB
stdin
4 8
2 7 5 6
stdout
1 4