結果

問題 No.133 カードゲーム
ユーザー T_shinobuT_shinobu
提出日時 2019-08-15 03:58:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 38 ms / 5,000 ms
コード長 1,013 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 10,192 KB
最終ジャッジ日時 2023-10-19 18:28:28
合計ジャッジ時間 2,074 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
seen = [0 for i in range(2*n)]
p = []
num = []
win_count = 0
match_count = 0
def dfs(x):
    global win_count
    global match_count
    if sum(seen) == 2*n:
        count = 0
        for i in range(n):
            if a[p[i]] > b[p[i+n]-n]:
                count += 1
        if count / n > 0.50:
            win_count += 1
        match_count += 1
        return

    for i in range(2*n):
        length = len(p)
        if length < n and i < n:
            if seen[i] == 0:
                seen[i] = 1
                p.append(i)
                dfs(i)
                seen[i] = 0
                p.pop()
        if length >= n and i >= n:
            if seen[i] == 0:
                seen[i] = 1
                p.append(i)
                dfs(i)
                seen[i] = 0
                p.pop()

for i in range(n):
    seen[i] = 1
    p.append(i)
    dfs(i)
    seen[i] = 0
    p.pop()
print(win_count / match_count)
0