結果

問題 No.289 数字を全て足そう
ユーザー uchida_tuchida_t
提出日時 2023-05-31 13:00:00
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 390 ms / 1,000 ms
コード長 254 bytes
コンパイル時間 15,360 ms
コンパイル使用メモリ 413,732 KB
実行使用メモリ 53,896 KB
最終ジャッジ日時 2023-08-28 01:29:36
合計ジャッジ時間 25,790 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 297 ms
52,700 KB
testcase_01 AC 295 ms
52,768 KB
testcase_02 AC 293 ms
52,832 KB
testcase_03 AC 296 ms
52,568 KB
testcase_04 AC 295 ms
53,028 KB
testcase_05 AC 325 ms
53,160 KB
testcase_06 AC 319 ms
53,116 KB
testcase_07 AC 377 ms
53,548 KB
testcase_08 AC 380 ms
53,352 KB
testcase_09 AC 324 ms
53,092 KB
testcase_10 AC 330 ms
53,188 KB
testcase_11 AC 349 ms
53,064 KB
testcase_12 AC 387 ms
53,424 KB
testcase_13 AC 335 ms
53,064 KB
testcase_14 AC 383 ms
53,728 KB
testcase_15 AC 353 ms
53,124 KB
testcase_16 AC 331 ms
53,136 KB
testcase_17 AC 378 ms
53,736 KB
testcase_18 AC 390 ms
53,896 KB
testcase_19 AC 354 ms
53,312 KB
testcase_20 AC 382 ms
53,368 KB
testcase_21 AC 291 ms
52,720 KB
testcase_22 AC 384 ms
53,424 KB
testcase_23 AC 358 ms
53,100 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:5:9: warning: condition 'result != null' is always 'true'
    if (result != null) {
        ^
Main.kt:6:35: warning: 'sumBy((T) -> Int): Int' is deprecated. Use sumOf instead.
        println(result.chunked(1).sumBy { it.toInt() })
                                  ^

ソースコード

diff #

fun main(args: Array<String>) {
    val text = readLine()!!
    val regex = Regex("[^0-9]")
    val result = regex.replace(text, "")
    if (result != null) {
        println(result.chunked(1).sumBy { it.toInt() })
    } else {
        println(0)
    }
}
0