forked from damaohongtu/JavaInterview
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChildrenDay.java
More file actions
47 lines (45 loc) · 1.4 KB
/
Copy pathChildrenDay.java
File metadata and controls
47 lines (45 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package NiuKeWang;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
/**
* @Classname ChildrenDay
* @Description TODO
* @Date 19-3-17 上午10:05
* @Created by mao<[email protected]>
*/
public class ChildrenDay {
public static void main(String[] args)throws IOException {
InputStreamReader ir=new InputStreamReader(System.in);
BufferedReader bf=new BufferedReader(ir);
int n = Integer.parseInt(bf.readLine());
String[] children = bf.readLine().split(" ");
int m=Integer.parseInt(bf.readLine());
String[] chocolate=bf.readLine().split(" ");
int [] children1=new int[children.length];
int [] chocolate1=new int[chocolate.length];
for(int i=0;i<children.length;i++){
children1[i]=Integer.parseInt(children[i]);
}
for(int j=0;j<chocolate.length;j++){
chocolate1[j]=Integer.parseInt(chocolate[j]);
}
Arrays.sort(children1);
Arrays.sort(chocolate1);
int i=0,j=0;
int count=0;
String s="";
while (i<children1.length && j<chocolate1.length){
if(children1[i]<=chocolate1[j]){
count++;
i++;
j++;
}
if(children1[i]>chocolate1[j]){
j++;
}
}
System.out.println(count);
}
}