From 1764ffbab29c7c62827ddce6ccc6cd57fe431a2c Mon Sep 17 00:00:00 2001 From: oncsr Date: Wed, 18 Jun 2025 17:02:14 +0900 Subject: [PATCH] =?UTF-8?q?[20250617]=20BOJ=20/=20P5=20/=20=EC=83=81?= =?UTF-8?q?=EB=82=A8=EC=9E=90=20=EA=B3=BD=EC=B2=A0=EC=9A=A9=20/=20?= =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \352\263\275\354\262\240\354\232\251.md" | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 "khj20006/202506/18 BOJ P5 \354\203\201\353\202\250\354\236\220 \352\263\275\354\262\240\354\232\251.md" diff --git "a/khj20006/202506/18 BOJ P5 \354\203\201\353\202\250\354\236\220 \352\263\275\354\262\240\354\232\251.md" "b/khj20006/202506/18 BOJ P5 \354\203\201\353\202\250\354\236\220 \352\263\275\354\262\240\354\232\251.md" new file mode 100644 index 00000000..c2e6c339 --- /dev/null +++ "b/khj20006/202506/18 BOJ P5 \354\203\201\353\202\250\354\236\220 \352\263\275\354\262\240\354\232\251.md" @@ -0,0 +1,111 @@ +```java +import java.math.BigInteger; +import java.util.*; +import java.io.*; + +class IOController { + BufferedReader br; + BufferedWriter bw; + StringTokenizer st; + + public IOController() { + br = new BufferedReader(new InputStreamReader(System.in)); + bw = new BufferedWriter(new OutputStreamWriter(System.out)); + st = new StringTokenizer(""); + } + + String nextLine() throws Exception { + String line = br.readLine(); + st = new StringTokenizer(line); + return line; + } + + String nextToken() throws Exception { + while (!st.hasMoreTokens()) nextLine(); + return st.nextToken(); + } + + int nextInt() throws Exception { + return Integer.parseInt(nextToken()); + } + + long nextLong() throws Exception { + return Long.parseLong(nextToken()); + } + + double nextDouble() throws Exception { + return Double.parseDouble(nextToken()); + } + + void close() throws Exception { + bw.flush(); + bw.close(); + } + + void write(String content) throws Exception { + bw.write(content); + } + +} + +public class Main { + + static IOController io; + + // + + static int N, M, K, base; + static List A; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + public static void init() throws Exception { + + N = io.nextInt(); + M = io.nextInt(); + K = io.nextInt(); + + boolean[] ex = new boolean[4*N+1]; + for(int i=0;i(); + for(int i=1;i<=4*N;i++) if(!ex[i]) A.add(i%K); + + } + + static void solve() throws Exception { + + Collections.sort(A); + int e = A.size() - 1, s = A.size()/2, ans = 0; + while(s >= 0) { + int a = A.get(e), b = A.get(s); + if(a-b > base) { + e--; + ans++; + } + s--; + } + io.write(Math.min(ans, M-1) + "\n"); + + + } + +} +```