forked from builder-of-web3/HackR_Java_Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPromNight.java
More file actions
74 lines (71 loc) · 1.78 KB
/
PromNight.java
File metadata and controls
74 lines (71 loc) · 1.78 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
public class PromNight {
public static void main(String args[]) throws Exception {
//Read Input.
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int N = Integer.parseInt(line);
N = N + 2;
ArrayList<String> arint = new ArrayList<String>();
ArrayList<Integer> boys = new ArrayList<Integer>();
int count[] = new int[2];
ArrayList<Integer> girls = new ArrayList<Integer>();
for (int i = 0; i < N; i++) {
arint.add(br.readLine());
}
//Create Proper DataStructure.
for(int i = 0; i < N; i++){
System.out.println(arint.get(i));
String str = arint.get(i);
String[] splitStr = str.split("\\s+");
if(i == 0){
for(int j=0;j<splitStr.length;j++){
count[j] = Integer.parseInt(splitStr[j]);
}
}
if(i == 1){
for(int k=0;k<splitStr.length;k++){
boys.add(Integer.parseInt(splitStr[k]));
}
}
if(i == 2){
for(int j=0;j<splitStr.length;j++){
girls.add(Integer.parseInt(splitStr[j]));
}
}
}
//Apply Problem Logic.
if(count[0] <= count[1]){
//System.out.println(boys);
Collections.sort(boys);
//System.out.println(boys);
//System.out.println(girls);
Collections.sort(girls);
//System.out.println(girls);
int pairCount = 0;
for(int i=0;i<boys.size();i++){
boolean pair=false;
//System.out.println("for"+i);
for(int j=0;j<girls.size();j++){
if(girls.get(j) < boys.get(i)){
pair = true;
}
}
if(pair){
pairCount++;
}
}
if(pairCount >= boys.size()){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
else{
System.out.println("NO");
}
}
}