题解,首AC
2024-05-16 21:57:49
发布于:浙江
18阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}//快读YYDS
int main() {
int n = read(), m = read(), a[n + 1];
for (int i = 1; i <= n; ++i)a[i] = read();
while (m--) {
int tmp = read();
int ans = lower_bound(a + 1, a + n + 1, tmp) - a;
a[ans] == tmp&&ans <= n/*记得特判*/ ? cout << ans << " " : cout << -1 << " ";
}
return 0;
}
这里空空如也
有帮助,赞一个