asdfg11 @ 2023-06-02 16:47:13
#include <iostream>
using namespace std;
const int N = 1e6 + 10;
int q[N];
int n, m;
int main()
{
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; i ++) scanf("%d", &q[i]);
while(m --)
{
int x;
scanf("%d", &x);
int l = 1, r = n;
while(l < r)
{
int mid = l + r >> 1;
if(q[mid] >= x) r = mid;
else l = mid + 1;
}
if(q[l] != x) printf("-1");
else printf("%d ", l);
}
return 0;
}
by liupan2010 @ 2023-06-02 18:10:55
by asdfg11 @ 2023-06-09 16:19:41
@liupan2010 我咋说全wa明明代码思路没错,原来是错在这了谢谢大佬提醒