题目描述
blablabla
样例
n, q = map(int, input().split())
nums = list(map(int, input().split()))
for i in range(q):
x = int(input())
l , r = 0, n - 1
while l < r:
mid = l + r >> 1
if nums[mid] >= x:
r = mid
else:
l = mid + 1
if nums[l] != x:
print("-1 -1")
else:
print(l, end = " ")
l , r = 0, n - 1
while l < r:
mid = l + r + 1 >> 1
if nums[mid] <= x:
l = mid
else: r = mid - 1
print(l)
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla