Advertisement
Josif_tepe

Untitled

May 4th, 2025
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6.  
  7. int main() {
  8.     int n;
  9.     cin >> n;
  10.    
  11.     vector<int> v;
  12.     for(int i = 0; i < n; i++) {
  13.         int x;
  14.         cin >> x;
  15.         v.push_back(x);
  16.     }
  17.    
  18.     sort(v.begin(), v.end());
  19.     int x;
  20.     cin >> x;
  21.    
  22.     int idx = lower_bound(v.begin(), v.end(), x) - v.begin();
  23.     if(idx >= 0 and idx < v.size()) {
  24.         cout << v[idx] << endl;
  25.     }
  26.     else {
  27.         cout <<"VAKOV ELEMENT NE POSTOI" << endl;
  28.     }
  29.    
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement