Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <cstring>
- using namespace std;
- int main() {
- int visina, n;
- cin >> visina >> n;
- vector<int> v(n);
- for(int i = 0; i < n; i++) {
- cin >> v[i];
- }
- visina += 5;
- int L = 0;
- int R = n - 1;
- while(L < R) {
- int middle = L + (R - L) / 2;
- if(visina <= v[middle]) {
- R = middle;
- }
- else {
- L = middle + 1;
- }
- }
- if(L < n and v[L] < visina) {
- L++;
- }
- cout << L << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement