Skip to content

[판다] 8주차 과제 제출 #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d3f4ce2
Create java_20922_panda.java
woong7 Jul 25, 2022
1882ceb
Delete java_5904_panda.java
woong7 Jul 25, 2022
9aca05b
Delete java_6198_panda.java
woong7 Jul 25, 2022
95f3dfc
Create java_5904_panda_1.java
woong7 Jul 25, 2022
7266c80
Create java_6198_panda_1.java
woong7 Jul 25, 2022
43e3174
Rename 5주차/java_6198_panda_1.java to 5주차/6198/java_6198_panda_1.java
woong7 Jul 25, 2022
30be19f
Create java_5107_panda.java
woong7 Jul 25, 2022
344658f
Create java_16432_panda.java
woong7 Jul 25, 2022
15a6735
Update java_5904_panda_1.java
woong7 Jul 25, 2022
18cff3b
Create java_5904_panda.java
woong7 Jul 25, 2022
53d816c
Create java_6198_panda.java
woong7 Jul 25, 2022
f9d5f09
Create java_11582_panda.java
woong7 Jul 25, 2022
b6724b7
Merge branch 'woowacourse-study:main' into main
woong7 Aug 2, 2022
2200ad7
Create java_25391_panda.java
woong7 Aug 6, 2022
9e67704
Update and rename java_25391_panda.java to java_14938_panda.java
woong7 Aug 6, 2022
8ef56ea
Create java_24229_panda.java
woong7 Aug 6, 2022
80bfd7a
Create java_24393_panda.java
woong7 Aug 6, 2022
e635af9
Create java_25391_panda.java
woong7 Aug 6, 2022
fc5bf99
Merge branch 'woowacourse-study:main' into main
woong7 Aug 13, 2022
a8c552c
Create java_13905_panda.java
woong7 Aug 13, 2022
87620e5
Create java_24499_panda.java
woong7 Aug 13, 2022
97dc6de
Create java_16288_panda.java
woong7 Aug 13, 2022
2e5dc0c
Update java_13905_panda.java
woong7 Aug 13, 2022
b1f1347
Create java_9694_panda.java
woong7 Aug 13, 2022
22012f4
Merge branch 'woowacourse-study:main' into main
woong7 Aug 20, 2022
0a70629
Create java_16498_panda.java
woong7 Aug 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions 8주차/16498/java_16498_panda.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package algorithm_study.week8;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class java_16498_panda {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

StringTokenizer st = new StringTokenizer(br.readLine());
int aNum = Integer.parseInt(st.nextToken());
int bNum = Integer.parseInt(st.nextToken());
int cNum = Integer.parseInt(st.nextToken());

TreeSet<Integer> A = new TreeSet<>();
TreeSet<Integer> B = new TreeSet<>();
TreeSet<Integer> C = new TreeSet<>();

st = new StringTokenizer(br.readLine());
for (int i = 0; i < aNum; i++) {
A.add(Integer.parseInt(st.nextToken()));
}
st = new StringTokenizer(br.readLine());
for (int i = 0; i < bNum; i++) {
B.add(Integer.parseInt(st.nextToken()));
}
st = new StringTokenizer(br.readLine());
for (int i = 0; i < cNum; i++) {
C.add(Integer.parseInt(st.nextToken()));
}

int answer = 100_000_000;

for (int a : A) {
Integer bCeil = B.ceiling(a);
if (Objects.nonNull(bCeil)) {
if (C.subSet(a, true, bCeil, true).isEmpty()) {
Integer cCeil = C.ceiling(bCeil);
if (Objects.nonNull(cCeil)) {
answer = Math.min(answer, cCeil - a);
}

Integer cFloor = C.floor(a);
if (Objects.nonNull(cFloor)) {
answer = Math.min(answer, bCeil - cFloor);
}
} else {
answer = Math.min(answer, bCeil - a);
}
}

Integer bFloor = B.floor(a);
if (Objects.nonNull(bFloor)) {
if (C.subSet(bFloor, true, a, true).isEmpty()) {
Integer cCeil = C.ceiling(a);
if(Objects.nonNull(cCeil)){
answer = Math.min(answer, cCeil - bFloor);
}

Integer cFloor = C.floor(bFloor);
if(Objects.nonNull(cFloor)){
answer = Math.min(answer , a - cFloor);
}

} else {
answer = Math.min(answer, a - bFloor);
}
}
}
System.out.println(answer);
}
}