-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeorgeAndRound.java
More file actions
40 lines (34 loc) · 848 Bytes
/
GeorgeAndRound.java
File metadata and controls
40 lines (34 loc) · 848 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
/* https://codeforces.com/contest/387/problem/B
#greedy #two-pointer
compare min-element of arrays B and arrays A,
max-element of arrays B and arrays A,
*/
import java.util.Scanner;
public class GeorgeAndRound {
static int calMinNeededProblem() {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int[] arrA = new int[n];
for (int i = 0; i < n; i++) {
int temp = scanner.nextInt();
arrA[i] = temp;
}
int result = n;
int j = 0;
for (int i = 0; i < m; i++) {
int temp = scanner.nextInt();
if (temp >= arrA[j]) {
result--;
j++;
}
if (j >= n || result == 0) {
break;
}
}
return result;
}
public static void main(String args[]) {
System.out.println(calMinNeededProblem());
}
}