• 문제 링크
https://www.acmicpc.net/problem/17048
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = read();
int[] a = new int[n], b = new int[n];
for (int i = 0; i < n; i++) a[i] = read();
for (int i = 0; i < n; i++) b[i] = read();
Map<Integer, Integer> map = new HashMap<>();
while (n-- > 0) map.put(b[n] - a[n], map.getOrDefault(b[n] - a[n], 0) + 1);
int max = 0;
for (int val : map.values()) max = Math.max(max, val);
bw.write(String.valueOf(max));
bw.flush();
}
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' 카테고리의 다른 글
[백준] 27160 할리갈리 - Data Structure / Java (0) | 2024.10.22 |
---|---|
[백준] 6513 Deli Deli - Data Structure / Java (0) | 2024.10.21 |
[백준] 24793 Shiritori - Data Structure / Java (0) | 2024.10.19 |
[백준] 10103 주사위 게임 - Implementation / Java (0) | 2024.10.18 |
[백준] 2914 저작권 - Implementation / Java (0) | 2024.10.17 |
댓글