Advertisement
Josif_tepe

Untitled

Mar 30th, 2024
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <map>
  5. using namespace std;
  6.  
  7. int main() {
  8.     int n;
  9.     cin >> n;
  10.     int k;
  11.     cin >> k;
  12.     int niza[n];
  13.    
  14.     for(int i = 0; i < n; i++) {
  15.         cin >> niza[i];
  16.     }
  17.    
  18.     map<int, int> m;
  19.    
  20.     for(int i = 0; i < n; i++) {
  21.         int razlika = k - niza[i];
  22.         if(m.count(razlika)) {
  23.             cout << i + 1 << " " << m[razlika] + 1 << endl;
  24.         }
  25.        
  26.         m[niza[i]] = i;
  27.     }
  28.    
  29.         return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement