File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments