望着时间滴答滴答的流过,我不曾改变过 . . .

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

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));
    }
}
posted @ 2019-04-08 22:28  whyaza  阅读(166)  评论(0编辑  收藏  举报