結果

問題 No.133 カードゲーム
ユーザー illumination-killumination-k
提出日時 2019-12-13 00:14:50
言語 Nim
(2.0.2)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 724 bytes
コンパイル時間 4,501 ms
コンパイル使用メモリ 71,884 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 07:13:48
合計ジャッジ時間 5,644 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils, algorithm

let N = stdin.readline.parseInt

var
    A = stdin.readLine.split.map(parseInt).sorted()
    B = stdin.readLine.split.map(parseInt).sorted()
    aPerm = newSeq[seq[int]]()
    bPerm = newSeq[seq[int]]()
    cnt = 0
    general_aWin = 0

while true:
    aPerm.add(A)
    if A.nextPermutation() == false: break

while true:
    bPerm.add(B)
    if B.nextPermutation() == false: break

for a in aPerm:
    for b in bPerm:
        inc cnt
        var
            aWin = 0
            bWin = 0
        for i in 0..<N:
            if a[i] > b[i]:
                inc aWin
            else:
                inc bWin

        if aWin > bWin:
            inc general_aWin


echo general_aWin/cnt
0