Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int m;
- cin >> m;
- vector <int> a;
- for (int i = 0; i < n; i++) {
- int z;
- cin >> z;
- a.push_back(z);
- }
- int low = 0;
- int high = a.size() - 1;
- while (high - low > 0) {
- int mid = (low + high) / 2;
- if (a[mid] > m) {
- low = mid;
- }else {
- high = mid;
- }
- }
- cout << high;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement