二分题不会ToT,有没有大佬教我

学术版

```cpp #include <iostream> using namespace std; const int MAXN = 1e5 + 10; int a[MAXN]; int main() { int N, M; cin >> N >> M; for (int i = 0; i < N; ++i) { cin >> a[i]; } for (int i = 0; i < M; ++i) { int x; cin >> x; int left = 0, right = N - 1, result = -1; while (left <= right) { int mid = left + (right - left) / 2; if (a[mid] < x) { result = mid; left = mid + 1; } else { right = mid - 1; } } cout << result << endl; } return 0; } ``` @[ym_612_04](/user/1338122) ???这不是模板题吗?
by qwertyuiop951357 @ 2024-04-29 22:08:53


@[qwertyuiop951357](/user/991301) 不是模版ToT,题目改了一点,模版我倒是会做[捂脸]
by ym_612_04 @ 2024-04-30 20:37:08


|