結果

問題 No.267 トランプソート
ユーザー バカらっくバカらっく
提出日時 2023-01-26 01:54:18
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 296 ms / 1,000 ms
コード長 703 bytes
コンパイル時間 11,747 ms
コンパイル使用メモリ 425,444 KB
実行使用メモリ 58,808 KB
最終ジャッジ日時 2023-09-09 09:03:01
合計ジャッジ時間 20,196 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 290 ms
57,016 KB
testcase_01 AC 284 ms
56,792 KB
testcase_02 AC 284 ms
56,796 KB
testcase_03 AC 271 ms
52,880 KB
testcase_04 AC 286 ms
56,688 KB
testcase_05 AC 288 ms
56,928 KB
testcase_06 AC 290 ms
57,032 KB
testcase_07 AC 294 ms
56,984 KB
testcase_08 AC 294 ms
57,044 KB
testcase_09 AC 288 ms
58,732 KB
testcase_10 AC 292 ms
56,856 KB
testcase_11 AC 291 ms
57,216 KB
testcase_12 AC 291 ms
56,988 KB
testcase_13 AC 290 ms
56,764 KB
testcase_14 AC 289 ms
57,012 KB
testcase_15 AC 290 ms
58,808 KB
testcase_16 AC 296 ms
56,836 KB
testcase_17 AC 295 ms
56,740 KB
testcase_18 AC 292 ms
56,704 KB
testcase_19 AC 290 ms
57,200 KB
testcase_20 AC 289 ms
57,120 KB
testcase_21 AC 291 ms
56,840 KB
testcase_22 AC 288 ms
57,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:2:9: warning: variable 'n' is never used
    val n = readLine()!!.toInt()
        ^

ソースコード

diff #

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val cards = readLine()!!.split(" ").map { Card(it) }.sorted()
    println(cards.map { it.value }.joinToString(" "))
}

data class Card(val value:String):Comparable<Card> {
    override fun compareTo(other: Card): Int {
        val suit = "DCHS"
        val idx1 = suit.indexOf(value[0])
        val idxOther1 = suit.indexOf(other.value[0])
        if(idx1 == idxOther1) {
            val number = "A23456789TJQK"
            val subIdx1 = number.indexOf(value[1])
            val subIdxOther = number.indexOf(other.value[1])
            return subIdx1.compareTo(subIdxOther)
        }
        return idx1.compareTo(idxOther1)
    }

}
0