結果

問題 No.1020 Reverse
ユーザー da_louisda_louis
提出日時 2020-04-10 21:54:05
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 416 ms / 2,000 ms
コード長 309 bytes
コンパイル時間 15,037 ms
コンパイル使用メモリ 415,924 KB
実行使用メモリ 57,796 KB
最終ジャッジ日時 2023-10-14 00:25:19
合計ジャッジ時間 24,016 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 300 ms
52,724 KB
testcase_01 AC 293 ms
52,684 KB
testcase_02 AC 295 ms
52,636 KB
testcase_03 AC 293 ms
52,844 KB
testcase_04 AC 296 ms
52,680 KB
testcase_05 AC 300 ms
52,776 KB
testcase_06 AC 295 ms
52,664 KB
testcase_07 AC 369 ms
53,048 KB
testcase_08 AC 401 ms
56,632 KB
testcase_09 AC 402 ms
54,596 KB
testcase_10 AC 416 ms
57,268 KB
testcase_11 AC 415 ms
57,796 KB
testcase_12 AC 403 ms
56,732 KB
testcase_13 AC 395 ms
57,316 KB
testcase_14 AC 408 ms
57,432 KB
testcase_15 AC 389 ms
54,664 KB
testcase_16 AC 397 ms
54,664 KB
testcase_17 AC 397 ms
57,336 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) = p1020()
         ^

ソースコード

diff #

fun main(args: Array<String>) = p1020()

fun p1020() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val s = readLine()!!

    if (n == k) return println(s.reversed())

    val answer = s.drop(k - 1) + s.take(k - 1).let { if ((n - k) % 2 == 0) it.reversed() else it }

    println(answer)
}
0