From 70b11d8f5649808091f7c1de986d89181e061263 Mon Sep 17 00:00:00 2001 From: oncsr Date: Tue, 12 Aug 2025 23:49:13 +0900 Subject: [PATCH] =?UTF-8?q?[20250812]=20BOJ=20/=20P3=20/=20=EC=8A=88?= =?UTF-8?q?=ED=8D=BC=20=ED=8A=B8=EB=A6=AC=20=EB=BD=80=EA=B0=9C=EA=B8=B0=20?= =?UTF-8?q?/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4 \353\275\200\352\260\234\352\270\260.md" | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 "khj20006/202508/12 BOJ P3 \354\212\210\355\215\274 \355\212\270\353\246\254 \353\275\200\352\260\234\352\270\260.md" diff --git "a/khj20006/202508/12 BOJ P3 \354\212\210\355\215\274 \355\212\270\353\246\254 \353\275\200\352\260\234\352\270\260.md" "b/khj20006/202508/12 BOJ P3 \354\212\210\355\215\274 \355\212\270\353\246\254 \353\275\200\352\260\234\352\270\260.md" new file mode 100644 index 00000000..30f1872c --- /dev/null +++ "b/khj20006/202508/12 BOJ P3 \354\212\210\355\215\274 \355\212\270\353\246\254 \353\275\200\352\260\234\352\270\260.md" @@ -0,0 +1,123 @@ +```java +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; + static long K; + static List[] graph; + static long[] v; + static PriorityQueue[] s; + static int ans = 0; + + public static void main(String[] args) throws Exception { + + io = new IOController(); + + init(); + solve(); + + io.close(); + + } + + static void init() throws Exception { + + N = io.nextInt(); + K = io.nextLong(); + graph = new ArrayList[N+1]; + v = new long[N+1]; + s = new PriorityQueue[N+1]; + for(int i=1;i<=N;i++) { + graph[i] = new ArrayList<>(); + s[i] = new PriorityQueue<>((a,b) -> Long.compare(b,a)); + s[i].add(0L); + } + for(int i=1;i s[n].size()) { + v[i] += x; + for(long j:s[n]) s[i].add(j+v[n]-v[i]); + s[n].clear(); + s[n] = s[i]; + v[n] = v[i]; + } + else { + for(long j:s[i]) s[n].add(j+x+v[i]-v[n]); + } + } + while(!s[n].isEmpty() && s[n].peek() + v[n] > K) s[n].poll(); + ans = Math.max(ans, s[n].size()); + } + +} +```