• 문제 링크
https://www.acmicpc.net/problem/17093
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
Pair[] p = new Pair[read()], q = new Pair[read()];
for (int i = 0; i < p.length; i++) p[i] = new Pair(read(), read());
for (int i = 0; i < q.length; i++) q[i] = new Pair(read(), read());
double max = 0;
for (Pair i : p) for (Pair j : q) max = Math.max(max, Math.pow(i.y - j.y, 2) + Math.pow(i.x - j.x, 2));
bw.write(String.valueOf((long) max));
bw.flush();
}
private static class Pair {
int y, x;
Pair(int y, int x) {
this.y = y;
this.x = x;
}
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
boolean flag = n == 13;
if (flag) n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return flag ? ~n + 1 : n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 9076 점수 집계 - Implementation / Java (0) | 2025.01.11 |
---|---|
[백준] 6124 Good Grass - Brute Force / Java (0) | 2025.01.10 |
[백준] 7280 Kortos - Brute Force / Java (0) | 2025.01.08 |
[백준] 22421 Koto Municipal Subway - Brute Force / Java (0) | 2025.01.07 |
[백준] 10432 데이터 스트림의 섬 - Brute Force / Java (0) | 2025.01.06 |
댓글