二分法-开花
样例输入 4 4 5 1 7 3 2 3 4 1 样例输出 1 3 import java . util . Arrays ; import java . util . Scanner ; public class 开花 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long [ ] a = new long [ 100005 ] ; long [ ] b = new long [ 100005 ] ; // int [] b=new int[m]; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } Arrays . sort ( b , 0 , m ) ; for ( int i = 0 ; i < n ; i ++ ) { int x = Arrays . binarySearch ( b , 0 , m , a [ i ] )