結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-28 09:31:21 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 5,000 ms |
| コード長 | 551 bytes |
| コンパイル時間 | 89 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-06-25 03:48:50 |
| 合計ジャッジ時間 | 1,602 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
from math import factorial
cnt = 0
def dfs(depth, N, p, mask):
global cnt
if depth == N:
wc = 0
for i, j in enumerate(p):
if A[j] > B[i]:
wc += 1
if 2*wc > N:
cnt += 1
return
for i in range(N):
if not(mask & (1 << i)):
p[depth] = i
dfs(depth + 1, N, p, mask ^ (1 << i))
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
p = [0] * N
dfs(0, N, p, 0)
ans = cnt / factorial(N)
print(ans)