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()); + } + +} +```