From 4cd6acb826a5ede2c5d3808fa80eb1c17b9ca57d Mon Sep 17 00:00:00 2001 From: soopeach Date: Sat, 3 Dec 2022 15:17:50 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Feat:=20=EA=B7=B8=EB=A3=B9=20=EB=8B=A8?= =?UTF-8?q?=EC=96=B4=20=EC=B2=B4=EC=BB=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\226\264 \354\262\264\354\273\244.kt" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "src/main/kotlin/hyunsoo/12week/\352\267\270\353\243\271 \353\213\250\354\226\264 \354\262\264\354\273\244.kt" diff --git "a/src/main/kotlin/hyunsoo/12week/\352\267\270\353\243\271 \353\213\250\354\226\264 \354\262\264\354\273\244.kt" "b/src/main/kotlin/hyunsoo/12week/\352\267\270\353\243\271 \353\213\250\354\226\264 \354\262\264\354\273\244.kt" new file mode 100644 index 00000000..a8c11404 --- /dev/null +++ "b/src/main/kotlin/hyunsoo/12week/\352\267\270\353\243\271 \353\213\250\354\226\264 \354\262\264\354\273\244.kt" @@ -0,0 +1,38 @@ +package hyunsoo.`12week` + + +/** + * <문제> + * [그룹 단어 체커](https://www.acmicpc.net/problem/1316) + * + * 문자열을 순차탐색하며 등장한 문자들을 list에 담는다. + * 이전의 단어와 현재의 단어가 다를 때 바뀐단어가 기존에 등장했다면 그룹단어가 아님!! + */ +fun main() { + + val wordCnt = readln().toInt() + var groupWordCnt = 0 + + repeat(wordCnt) { + + val existedWordList = mutableListOf() + val targetWord = readln() + var lastChar = targetWord.first().apply { + existedWordList.add(this) + } + + targetWord.drop(1).forEach { curChar -> + if (lastChar != curChar) { + if (curChar in existedWordList) { + return@repeat + } else { + existedWordList.add(curChar) + lastChar = curChar + } + } + } + groupWordCnt++ + } + + println(groupWordCnt) +} From 371557af5a03e0be2024c71a2a0f75750dc2e6f2 Mon Sep 17 00:00:00 2001 From: soopeach Date: Sat, 3 Dec 2022 15:42:23 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Feat:=20=EC=88=98=EB=A6=AC=EA=B3=B5=20?= =?UTF-8?q?=ED=95=AD=EC=8A=B9=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\352\263\265 \355\225\255\354\212\271.kt" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "src/main/kotlin/hyunsoo/12week/\354\210\230\353\246\254\352\263\265 \355\225\255\354\212\271.kt" diff --git "a/src/main/kotlin/hyunsoo/12week/\354\210\230\353\246\254\352\263\265 \355\225\255\354\212\271.kt" "b/src/main/kotlin/hyunsoo/12week/\354\210\230\353\246\254\352\263\265 \355\225\255\354\212\271.kt" new file mode 100644 index 00000000..5f518e78 --- /dev/null +++ "b/src/main/kotlin/hyunsoo/12week/\354\210\230\353\246\254\352\263\265 \355\225\255\354\212\271.kt" @@ -0,0 +1,27 @@ +package hyunsoo.`12week` + +/** + * <문제> + * [수리공 항승](https://www.acmicpc.net/problem/1449) + * + * 물새는 곳을 하나씩 막아보자앗..!! + */ +fun main() { + + val (_, tapeLength) = readln().split(" ").map { it.toInt() } + val leakPositionList = readln().split(" ") + .map { it.toInt() } + .sorted() + + var lastTapedPosition = leakPositionList.first() + tapeLength - 0.5f + var tapedCnt = 1 + + leakPositionList.drop(1).forEach { leakPosition -> + if (lastTapedPosition < leakPosition) { + lastTapedPosition = leakPosition + tapeLength - 0.5f + tapedCnt++ + } + } + + println(tapedCnt) +} \ No newline at end of file From 4d4596750d505d984c89dd3d9fada0f0bee3ec1f Mon Sep 17 00:00:00 2001 From: soopeach Date: Sat, 3 Dec 2022 22:58:34 +0900 Subject: [PATCH 3/3] =?UTF-8?q?Feat:=20=ED=8A=B8=EB=9F=AD=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../12week/\355\212\270\353\237\255.kt" | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 "src/main/kotlin/hyunsoo/12week/\355\212\270\353\237\255.kt" diff --git "a/src/main/kotlin/hyunsoo/12week/\355\212\270\353\237\255.kt" "b/src/main/kotlin/hyunsoo/12week/\355\212\270\353\237\255.kt" new file mode 100644 index 00000000..bb5e94d9 --- /dev/null +++ "b/src/main/kotlin/hyunsoo/12week/\355\212\270\353\237\255.kt" @@ -0,0 +1,61 @@ +package hyunsoo.`12week` + +import java.util.ArrayDeque +import java.util.Queue + +/** + * <문제> + * [트럭](https://www.acmicpc.net/problem/13335) + * + * + */ + +data class Truck(var weight: Int, var pos: Int = 1) { + fun move() { + this.pos++ + } +} + +fun main() { + + val waitQueue: Queue = ArrayDeque() + val processQueue: Queue = ArrayDeque() + var usedTime = 1 + + val (_, bridgeLength, bridgeMaxWeight) = readln().split(" ").map { it.toInt() } + + readln().split(" ") + .map { it.toInt() } + .forEach { weight -> + waitQueue.add(Truck(weight)) + } + + var isArrived = false + while (waitQueue.isNotEmpty() || processQueue.isNotEmpty()) { + + usedTime++ + + // 최대 하중 무게만큼 트럭 올리기 + if (waitQueue.isNotEmpty() && + processQueue.sumOf { it.weight } + waitQueue.peek().weight <= bridgeMaxWeight + ) { + processQueue.add(waitQueue.poll()) + } + + // 트럭들 이동 + processQueue.forEach { truck -> + truck.apply { + move() + if (bridgeLength < this.pos) isArrived = true + } + } + + if (isArrived) { + processQueue.poll() + isArrived = false + } + } + + println(usedTime) + +} \ No newline at end of file