From 283de109f1472bc0697f799e05e73cc9f11888c6 Mon Sep 17 00:00:00 2001 From: Jonghwan Lee <123362165+0224LJH@users.noreply.github.com> Date: Mon, 25 Aug 2025 15:08:31 +0900 Subject: [PATCH] =?UTF-8?q?[20250825]=20=20BOJ=20/=20G5=20/=20=EC=A2=8B?= =?UTF-8?q?=EB=8B=A4=20/=20=EC=9D=B4=EC=A2=85=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../25 BOJ \354\242\213\353\213\244.md" | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 "0224LJH/202508/25 BOJ \354\242\213\353\213\244.md" diff --git "a/0224LJH/202508/25 BOJ \354\242\213\353\213\244.md" "b/0224LJH/202508/25 BOJ \354\242\213\353\213\244.md" new file mode 100644 index 00000000..080bfe71 --- /dev/null +++ "b/0224LJH/202508/25 BOJ \354\242\213\353\213\244.md" @@ -0,0 +1,87 @@ +```java +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.StringTokenizer; + + +public class Main { + + static int numCnt,ans; + static int[] arr; + static HashMap> good; + + public static void main(String[] args) throws IOException { + init(); + process(); + print(); + } + + public static void init() throws IOException { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + good = new HashMap<>(); + + numCnt = Integer.parseInt(br.readLine()); + arr =new int[numCnt]; + ans = 0; + + StringTokenizer st = new StringTokenizer(br.readLine()); + for (int i = 0; i < numCnt; i++) { + arr[i] = Integer.parseInt(st.nextToken()); + } + } + + public static void process() throws IOException { + for (int i = 0; i ()); + good.get(arr[i]).add(i); + } + } + + + for (int i = 0; i < numCnt; i++) { + for (int j = i+1; j < numCnt; j++){ + int sum = arr[i] + arr[j]; + + if (!good.containsKey(sum)) continue; + + HashSet idx = good.get(sum); + + boolean isRemovable = false; + + for (int n: idx) { + if (n != i && n != j) { + isRemovable = true; + break; + } + } + + if (isRemovable) good.remove(sum); + + } + } + + int zeroCnt = 0; + for (int i = 0; i < numCnt; i++) if(arr[i] == 0) zeroCnt++; + if (zeroCnt >= 3) good.remove(0); + + for (int i = 0; i < numCnt; i++) { + if (!good.containsKey(arr[i])) ans++; + } + + } + + + + public static void print() { + System.out.println(ans); + } +} + +```