Advertisement
Josif_tepe

Untitled

May 12th, 2024
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n, k;
  6.     cin >> n >> k;
  7.  
  8.     int niza[n];
  9.     for(int i = 0; i < n; i++) {
  10.         cin >> niza[i];
  11.     }
  12.  
  13.     map<int, int> mapa;
  14.     for(int i = 0; i < n; i++) {
  15.         if(mapa.count(k - niza[i])) {
  16.             cout << mapa[k - niza[i]] + 1 << " " << i + 1 << endl;
  17.             return 0;
  18.         }
  19.  
  20.         mapa[niza[i]] = i;
  21.     }
  22.     cout << "IMPOSSIBLE" << endl;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement