結果

問題 No.784 「,(カンマ)」
ユーザー バカらっくバカらっく
提出日時 2022-02-14 02:31:54
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 11,296 ms
コンパイル使用メモリ 417,832 KB
実行使用メモリ 52,972 KB
最終ジャッジ日時 2023-09-11 15:48:07
合計ジャッジ時間 16,232 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 270 ms
52,656 KB
testcase_01 AC 279 ms
52,972 KB
testcase_02 AC 276 ms
52,704 KB
testcase_03 AC 278 ms
52,856 KB
testcase_04 AC 268 ms
52,676 KB
testcase_05 AC 268 ms
52,644 KB
testcase_06 AC 266 ms
52,584 KB
testcase_07 AC 267 ms
52,648 KB
testcase_08 AC 266 ms
52,520 KB
testcase_09 AC 264 ms
52,884 KB
testcase_10 AC 272 ms
52,512 KB
testcase_11 AC 266 ms
52,516 KB
testcase_12 AC 273 ms
52,504 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:4:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

import java.lang.StringBuilder
import java.util.*

fun main(args: Array<String>) {
    val a = LinkedList<Char>().also { it.addAll(readLine()!!.trim().reversed().toList()) }
    val ans = StringBuilder()
    while (a.isNotEmpty()) {
        if(ans.isNotEmpty()) {
            ans.append(',')
        }
        repeat(3) {
            if(a.isNotEmpty()) {
                ans.append(a.pop())
            }
        }
    }
    println(ans.toString().reversed())
}
0