結果

問題 No.133 カードゲーム
ユーザー バカらっくバカらっく
提出日時 2019-10-03 10:33:39
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 333 ms / 5,000 ms
コード長 1,049 bytes
コンパイル時間 14,312 ms
コンパイル使用メモリ 443,652 KB
実行使用メモリ 57,292 KB
最終ジャッジ日時 2024-04-14 09:05:38
合計ジャッジ時間 22,702 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 320 ms
57,000 KB
testcase_01 AC 321 ms
57,024 KB
testcase_02 AC 314 ms
57,120 KB
testcase_03 AC 313 ms
56,944 KB
testcase_04 AC 315 ms
57,028 KB
testcase_05 AC 325 ms
57,140 KB
testcase_06 AC 323 ms
57,264 KB
testcase_07 AC 330 ms
57,204 KB
testcase_08 AC 313 ms
56,992 KB
testcase_09 AC 317 ms
57,116 KB
testcase_10 AC 328 ms
57,212 KB
testcase_11 AC 333 ms
57,220 KB
testcase_12 AC 328 ms
57,240 KB
testcase_13 AC 313 ms
57,084 KB
testcase_14 AC 317 ms
57,032 KB
testcase_15 AC 316 ms
56,996 KB
testcase_16 AC 325 ms
57,244 KB
testcase_17 AC 330 ms
57,292 KB
testcase_18 AC 323 ms
57,224 KB
testcase_19 AC 327 ms
57,096 KB
testcase_20 AC 326 ms
57,264 KB
testcase_21 AC 322 ms
57,068 KB
testcase_22 AC 324 ms
57,084 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args:Array<String>) {
         ^

ソースコード

diff #

fun main(args:Array<String>) {
    val turnCount = readLine()!!.toInt()
    val cards1 = readLine()!!.split(" ").map { it.toInt() }
    val cards2 = readLine()!!.split(" ").map { it.toInt() }

    val ans = getResult(cards1, cards2, 0, turnCount).let { it.first / it.second.toDouble() }
    println(ans)

}



fun getResult(myCards:List<Int>, otherCards:List<Int>, subTotal:Int, turnCount:Int):Pair<Int, Int> {
    if(myCards.size == 0) {
        return if(subTotal > (turnCount - subTotal)) 1 to 1 else 0 to 1
    }

    var winCount = 0 to 0

    for(i in myCards.indices) {
        val newMyCards = myCards.withIndex().filter { it.index != i }.map { it.value }
        for(j in otherCards.indices) {
            val newOtherCards = otherCards.withIndex().filter { it.index != j }.map { it.value }
            val ret = getResult(newMyCards, newOtherCards, if (myCards[i] > otherCards[j]) subTotal + 1 else subTotal, turnCount)
            winCount = winCount.first + ret.first to winCount.second + ret.second
        }
    }
    return winCount
}
0