diff --git "a/src/main/kotlin/byeonghee/8week/\353\213\250\354\266\225\355\202\244 \354\247\200\354\240\225.kt" "b/src/main/kotlin/byeonghee/8week/\353\213\250\354\266\225\355\202\244 \354\247\200\354\240\225.kt" new file mode 100644 index 00000000..1c4d3507 --- /dev/null +++ "b/src/main/kotlin/byeonghee/8week/\353\213\250\354\266\225\355\202\244 \354\247\200\354\240\225.kt" @@ -0,0 +1,31 @@ +package byeonghee.`8week` + +import java.io.* + +class `소병희_단축키 지정` { + + val br = BufferedReader(InputStreamReader(System.`in`)) + val keySet = HashSet() + + fun solution() { + val n = br.readLine().toInt() + + repeat(n) { + br.readLine().let { words -> + words.split(" ").firstOrNull { word -> + keySet.add(word[0].lowercaseChar()) + }?.let { key -> + println(words.replaceFirst(key, "[${key[0]}]${key.drop(1)}")) + } ?: words.replace(" ", "").firstOrNull { char -> + keySet.add(char.lowercaseChar()) + }?.let { key -> + println(words.replaceFirst("$key", "[$key]")) + } ?: println(words) + } + } + } +} + +fun main() { + `소병희_단축키 지정`().solution() +} \ No newline at end of file diff --git "a/src/main/kotlin/byeonghee/8week/\353\254\270\354\236\220\354\227\264 \354\247\221\355\225\251.kt" "b/src/main/kotlin/byeonghee/8week/\353\254\270\354\236\220\354\227\264 \354\247\221\355\225\251.kt" new file mode 100644 index 00000000..50e4ccd5 --- /dev/null +++ "b/src/main/kotlin/byeonghee/8week/\353\254\270\354\236\220\354\227\264 \354\247\221\355\225\251.kt" @@ -0,0 +1,28 @@ +package byeonghee.`8week` + +import java.io.* + +class `소병희_문자열 집합` { + + val br = BufferedReader(InputStreamReader(System.`in`)) + val hashMap = HashMap() + var answer = 0 + + fun solution() { + val (n, m) = br.readLine().split(" ").map{ it.toInt() } + + repeat(n) { + hashMap[br.readLine()] = true + } + + repeat(m) { + if (hashMap[br.readLine()] != null) answer++ + } + + println(answer) + } +} + +fun main() { + `소병희_문자열 집합`().solution() +} \ No newline at end of file diff --git "a/src/main/kotlin/byeonghee/8week/\354\203\211\354\242\205\354\235\264 \353\247\214\353\223\244\352\270\260.kt" "b/src/main/kotlin/byeonghee/8week/\354\203\211\354\242\205\354\235\264 \353\247\214\353\223\244\352\270\260.kt" new file mode 100644 index 00000000..2e70ec26 --- /dev/null +++ "b/src/main/kotlin/byeonghee/8week/\354\203\211\354\242\205\354\235\264 \353\247\214\353\223\244\352\270\260.kt" @@ -0,0 +1,47 @@ +package byeonghee.`8week` + +import java.io.* + +class `소병희_색종이 만들기` { + + data class Pos(val r: Int, val c: Int) + + val br = BufferedReader(InputStreamReader(System.`in`)) + lateinit var paper : Array + var white = 0 + var blue = 0 + + fun solution() { + val n = br.readLine().toInt() + paper = Array(n) { br.readLine().split(" ").map{ it.toInt() }.toIntArray() } + + quadTree(Pos(0, 0), n) + println(white) + println(blue) + } + + fun quadTree(p: Pos, l: Int) { + var count = 0 + for(r in p.r until p.r + l) for(c in p.c until p.c + l) { + if (paper[r][c] == 0) count++ + } + if (count == l * l) { + white++ + return + } + else if (count == 0) { + blue++ + return + } + + val nxtL = l / 2 + quadTree(p, nxtL) + quadTree(Pos(p.r + nxtL, p.c), nxtL) + quadTree(Pos(p.r, p.c + nxtL), nxtL) + quadTree(Pos(p.r + nxtL, p.c + nxtL), nxtL) + } +} + +fun main() { + `소병희_색종이 만들기`().solution() +} \ No newline at end of file diff --git "a/src/main/kotlin/byeonghee/8week/\354\207\240\353\247\211\353\214\200\352\270\260.kt" "b/src/main/kotlin/byeonghee/8week/\354\207\240\353\247\211\353\214\200\352\270\260.kt" new file mode 100644 index 00000000..ec4ac3e5 --- /dev/null +++ "b/src/main/kotlin/byeonghee/8week/\354\207\240\353\247\211\353\214\200\352\270\260.kt" @@ -0,0 +1,32 @@ +package byeonghee.`8week` + +import java.io.* + +class 소병희_쇠막대기 { + + val br = BufferedReader(InputStreamReader(System.`in`)) + var answer = 0 + var acc = 0 + + fun solution() { + val brackets = br.readLine().toCharArray() + + for(i in 1 until brackets.size) { + if (brackets[i] == '(' && brackets[i-1] == '(') acc++ + else if (brackets[i] == ')') { + if (brackets[i-1] == '(') { + answer += acc + } + else if (brackets[i-1] == ')') { + answer++ + acc-- + } + } + } + println(answer) + } +} + +fun main() { + 소병희_쇠막대기().solution() +} \ No newline at end of file diff --git "a/src/main/kotlin/byeonghee/8week/\354\260\275\352\263\240 \353\213\244\352\260\201\355\230\225.kt" "b/src/main/kotlin/byeonghee/8week/\354\260\275\352\263\240 \353\213\244\352\260\201\355\230\225.kt" new file mode 100644 index 00000000..cb3d64e7 --- /dev/null +++ "b/src/main/kotlin/byeonghee/8week/\354\260\275\352\263\240 \353\213\244\352\260\201\355\230\225.kt" @@ -0,0 +1,44 @@ +package byeonghee.`8week` + +import java.io.* +import java.util.PriorityQueue + +class `소병희_창고 다각형` { + + data class Pillar(val d: Int, val h: Int) + + val br = BufferedReader(InputStreamReader(System.`in`)) + val pq = PriorityQueue(Comparator{ a, b -> b.h - a.h }) + val storage = ArrayDeque() + var answer = 0 + + fun solution() { + val n = br.readLine().toInt() + repeat(n) { + br.readLine().split(" ").map{ it.toInt() }.let { + pq.add(Pillar(it[0], it[1])) + } + } + storage.add(pq.poll()) + + while(pq.isNotEmpty()) { + pq.poll().let { cur -> + if (cur.d < storage.first().d) { + answer += cur.h * (storage.first().d - cur.d) + storage.addFirst(cur) + } + else if (cur.d > storage.last().d) { + answer += storage.last().h + cur.h * (cur.d - storage.last().d - 1) + storage.addLast(cur) + } + } + } + answer += storage.last().h + + println(answer) + } +} + +fun main() { + `소병희_창고 다각형`().solution() +} \ No newline at end of file