Created
April 26, 2023 11:19
-
-
Save modos/370c5d8915b1979f1630e10fd0d6d93f to your computer and use it in GitHub Desktop.
جستوجو در دنباله ۲
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n, q = map(int, input().split()) | |
a = list(map(int, input().split())) | |
# M = a[1] | |
# for i in range(2, n): | |
# M = max(M, a[i]) | |
M = max(a) | |
cnt = [0 for i in range(M + 1)] | |
for i in range(0, n): | |
cnt[a[i]] += 1 | |
ps = [0 for i in range(M)] | |
for i in range(1, M): | |
ps[i] = ps[i - 1] + cnt[i] | |
for i in range(q): | |
x = int(input()) | |
if x > M: | |
print(n) | |
else: | |
print(ps[x-1]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment