用java写的,MLE
感觉数组也没开大
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] a = new int[n + 10];
for (int i = 1; i <= n; ++i)
a[i] = sc.nextInt();
while (m-- != 0) {
int q = sc.nextInt();
int l = 0, r = n + 1;
while (l + 1 < r) {
int mid = l + r >> 1;
if (a[mid] >= q)
r = mid;
else
l = mid;
}
if (a[r] == q)
System.out.print(r + " ");
else
System.out.print(-1 + " ");
}
}
}