Skip to content

Commit 9288204

Browse files
authored
[BOJ] 23351 물 주기 (S3)
1 parent 9058e92 commit 9288204

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

정건우/5주차/260126.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//https://www.acmicpc.net/problem/23351
2+
import java.io.BufferedReader;
3+
import java.io.IOException;
4+
import java.io.InputStreamReader;
5+
import java.util.PriorityQueue;
6+
import java.util.StringTokenizer;
7+
8+
public class BOJ_S3_23351_물주기 {
9+
public static void main(String[] args) throws IOException {
10+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
11+
StringTokenizer st = new StringTokenizer(br.readLine());
12+
13+
int N = Integer.parseInt(st.nextToken());
14+
int K = Integer.parseInt(st.nextToken());
15+
int A = Integer.parseInt(st.nextToken());
16+
int B = Integer.parseInt(st.nextToken());
17+
18+
PriorityQueue<Integer> pq = new PriorityQueue<>();
19+
20+
N = N % A == 0 ? N/A : N/A + 1;
21+
22+
for (int i = 0; i < N; i++) {
23+
pq.add(K);
24+
}
25+
26+
int ans = 0;
27+
28+
while (!pq.isEmpty() && ++ans <= pq.peek()) {
29+
pq.add(pq.poll()+B);
30+
}
31+
32+
System.out.println(ans-1);
33+
34+
}
35+
}

0 commit comments

Comments
 (0)