ICPC42 @ 2024-03-11 20:45:03
同一道题,Java就MLE,改成C就过了。
by LittleShi @ 2024-03-15 15:45:45
使用Java快读模板,可以上网搜一个
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner input = new Scanner(System.in);
Read read = new Read();
int n = read.nextInt();
int m = read.nextInt();
int[] a = new int[n];
for(int i = 0; i < n; i++){
a[i] = read.nextInt();
}
int[] b = new int[m];
for(int i = 0; i < m; i++){
b[i] = read.nextInt();
}
for(int j=0;j<b.length;j++){
int l = 0;int r = a.length-1;
while(l<r){
int mid = (l+r)/2;
if(b[j] <= a[mid]){
r= mid;
}else{
l = mid+1;
}
}
if(b[j] == a[l]){
System.out.print(l+1+" ");
}else{
System.out.print(-1+" ");
}
}
}
}
class Read{
StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
public int nextInt() throws Exception{
st.nextToken();
return (int)st.nval;
}
public String readLine() throws Exception{
st.nextToken();
return st.sval;
}
}
@ICPC42
@ICPC42