Advertisement
Josif_tepe

Untitled

Mar 3rd, 2022
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.     vector<int> v(n);
  10.     for(int i = 0; i < n; i++) {
  11.         cin >> v[i];
  12.     }
  13.     sort(v.begin(), v.end());
  14.     int x;
  15.     cin >> x;
  16.    
  17.     int idx = lower_bound(v.begin(), v.end(), x) - v.begin();
  18.    
  19.     if(idx >= 0 and idx < v.size()) {
  20.         cout << v[idx] << endl;
  21.     }
  22.    return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement