Advertisement
Josif_tepe

Untitled

May 12th, 2024
698
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 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.     for(int i = 0; i < n; i++) {
  14.         int sum = k - niza[i];
  15.         unordered_map<int, int> mapa;
  16.         for(int j = 0; j < n; j++) {
  17.             if(i != j) {
  18.                 if(mapa.count(sum - niza[j])) {
  19.                     cout << i + 1 << " " << mapa[sum - niza[j]] + 1 << " " << j + 1 << endl;
  20.                     return 0;
  21.                 }
  22.                 mapa[niza[j]] = j;
  23.             }
  24.         }
  25.     }
  26.  
  27.     cout << "IMPOSSIBLE" << endl;
  28.  
  29.        return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement