https://www.acmicpc.net/problem/1927
[난이도] Silver1
[유형] 우선순위큐
[풀이]
우선순위큐
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*
fun main() = with(BufferedReader(InputStreamReader(System.`in`))){
val pq = PriorityQueue<Int>()
var N = readLine().toInt()
while(N-->0){
var k = readLine().toInt()
when(k){
0 -> {
var t = 0
pq.poll()?.let{
t+=it
}
println(t)
}
else -> pq.add(k)
}
}
}
https://github.com/has2/Problem-Solving/blob/master/boj-solved.ac/Silver1/1927.cpp
'Problem-Solving > BOJ' 카테고리의 다른 글
[BOJ/백준][Silver1] 6064 : 카잉 달력 (C++) (0) | 2021.07.18 |
---|---|
[BOJ/백준][Silver2] 5525 : IOIOI (C++) (0) | 2021.07.18 |
[BOJ/백준][Silver4] 1764 : 듣보잡 (Kotlin) (0) | 2021.07.18 |
[BOJ/백준][Gold3] 9944 : NxM 보드 완주하기 (C++) (0) | 2021.07.10 |
[BOJ/백준][Gold2] 10775 : 공항 (C++) (0) | 2021.07.10 |