其他分享
首页 > 其他分享> > 牛客网 拼多多校招-六一儿童节

牛客网 拼多多校招-六一儿童节

作者:互联网

import java.io.*;
import java.util.*;

public class Main{
    public static int patch(int[] h,int[] w){
        Arrays.sort(h);
        Arrays.sort(w);
        int res = 0;
        int d = 0;
        for (int i=0;i < w.length;i++){
            for(int j=d;j < h.length;j++){
               if (w[i] >= h[j]){
                   d = j + 1;
                   res ++;
                   break;
               }
            }
        }
        return res;
    }
    public static void main(String[] args) throws IOException{
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int wn = Integer.parseInt(bf.readLine());
        String[] sh = bf.readLine().split(" ");
        int wm = Integer.parseInt(bf.readLine());
        String[] sm = bf.readLine().split(" ");
        
        int[] h = new int[sh.length];
        int[] m = new int[sm.length];
        for (int i = 0; i < sh.length; i++)
            h[i] = Integer.parseInt(sh[i]);
        for (int i = 0; i < sm.length; i++)
            m[i] = Integer.parseInt(sm[i]);
        System.out.println(patch(h, m));
    }
}

标签:bf,int,儿童节,++,牛客,length,parseInt,new,校招
来源: https://www.cnblogs.com/whyaza/p/10673991.html