-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrays.java
44 lines (37 loc) · 940 Bytes
/
Arrays.java
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
/* https://codeforces.com/contest/572/problem/A
tag: #sorting
find the first element (called j-th) in arrays B that
greater than the k-th element of arrays A and,
check if nB - j >= m
*/
import java.util.Scanner;
public class Arrays {
static String checkPossible() {
String result = "NO";
Scanner scanner = new Scanner(System.in);
int nA = scanner.nextInt();
int nB = scanner.nextInt();
int k = scanner.nextInt();
int m = scanner.nextInt();
int kThA = 0;
for (int i = 0; i < nA; i++) {
int temp = scanner.nextInt();
if (i == k - 1) {
kThA = temp;
}
}
for (int i = 0; i < nB; i++) {
int temp = scanner.nextInt();
if (temp > kThA) {
if (nB - i >= m) {
result = "YES";
}
break;
}
}
return result;
}
public static void main(String args[]) {
System.out.println(checkPossible());
}
}