문제 출처 : https://www.acmicpc.net/problem/5013
언어 : Kotlin
문제 설명 :
There once was a champion of WoW Arthasdk the name he was bestowed He Death Gripped you to his side His Chains of Ice stopped your stride And Obliterates made you say ”OWW!”
But one day our hero got puzzled His Death Grip totally fizzled In his darkest despair He could barely hear ”OMG NOOB u Chains of Iced than u Death Gripped”
입력 :
You are given a recording of the abilities our hero used in his battles.
The first line of input will contain a single integer n (1 ≤ n ≤ 100), the number of battles our hero played.
Then follow n lines each with a sequence of ki (1 ≤ ki ≤ 1000) characters, each of which are either ’C’, ’D’ or ’O’. These denote the sequence of abilities used by our hero in the i-th battle. ’C’ is Chains of Ice, ’D’ is Death Grip and ’O’ is Obliterate.
출력 :
Output the number of battles our hero won, assuming he won each battle where he did not Chains of Ice immediately followed by Death Grip.
제한 사항 :
- 시간 제한 : 1초
- 메모리 제한 : 128MB
입출력 예 :
입력 | 출력 |
3 DCOOO DODOCD COD |
2 |
풀이 :
import java.io.BufferedWriter
import java.io.OutputStreamWriter
fun main() = with(System.`in`.bufferedReader()) {
val bw = BufferedWriter(OutputStreamWriter(System.out))
var cnt = 0
repeat(readLine().toInt()) {
val cur = readLine()
if (!cur.contains("CD")) cnt++
}
bw.write("$cnt")
bw.flush()
bw.close()
}
'백준 > 문제' 카테고리의 다른 글
3512번: Flat (2) | 2024.09.23 |
---|---|
24937번: SciComLove(2022) (1) | 2024.09.20 |
10940번: BASE16 인코딩 (0) | 2024.09.20 |
21771번: 가희야 거기서 자는 거 아니야 (0) | 2024.09.19 |
1893번: 시저 암호 (0) | 2024.09.19 |
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!