-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSushi.java
More file actions
40 lines (39 loc) · 872 Bytes
/
Copy pathSushi.java
File metadata and controls
40 lines (39 loc) · 872 Bytes
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
import java.util.*;
public class Sushi
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
long[] shari = new long[N];
long[] neta = new long[M];
for (int i = 0; i < N; i++)
{
shari[i] = sc.nextLong();
}
for (int i = 0; i < M; i++)
{
neta[i] = sc.nextLong();
}
Arrays.sort(shari);
Arrays.sort(neta);
int i = 0;
int j = 0;
int count = 0;
while (i < N && j < M)
{
if (neta[j] <= 2 * shari[i])
{
count++;
i++;
j++;
}
else
{
i++;
}
}
System.out.println(count);
}
}