結果

問題 No.133 カードゲーム
ユーザー 山口日向山口日向
提出日時 2021-05-22 12:34:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 145 ms / 5,000 ms
コード長 1,639 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 82,716 KB
実行使用メモリ 89,704 KB
最終ジャッジ日時 2024-04-18 17:36:02
合計ジャッジ時間 4,404 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
83,596 KB
testcase_01 AC 123 ms
83,728 KB
testcase_02 AC 127 ms
83,328 KB
testcase_03 AC 121 ms
83,320 KB
testcase_04 AC 121 ms
83,336 KB
testcase_05 AC 136 ms
88,884 KB
testcase_06 AC 143 ms
89,164 KB
testcase_07 AC 132 ms
89,204 KB
testcase_08 AC 121 ms
83,380 KB
testcase_09 AC 122 ms
83,716 KB
testcase_10 AC 141 ms
89,704 KB
testcase_11 AC 134 ms
89,516 KB
testcase_12 AC 137 ms
89,520 KB
testcase_13 AC 120 ms
83,176 KB
testcase_14 AC 122 ms
83,468 KB
testcase_15 AC 121 ms
83,256 KB
testcase_16 AC 142 ms
89,308 KB
testcase_17 AC 136 ms
89,372 KB
testcase_18 AC 139 ms
89,500 KB
testcase_19 AC 145 ms
89,508 KB
testcase_20 AC 137 ms
89,240 KB
testcase_21 AC 136 ms
89,584 KB
testcase_22 AC 139 ms
89,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import copy, deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement, permutations
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
from operator import itemgetter
#import numpy as np #pypyでは使用不可
input = sys.stdin.readline
def int_input(): return int(input())
def int_map(): return map(int, input().split())
def int_list(): return list(int_map())
def int_row(N): return [int_input() for _ in range(N)]
def int_row_list(N): return [int_list() for _ in range(N)]
def str_input(): return input()[:-1]
def str_map(): return input().split()
def str_list(): return list(str_map())
def str_row(N): return [str_input() for _ in range(N)]
def str_row_list(N): return [list(str_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 10 ** 9 + 7
mod = 998244353

#メモリ消費を抑える時はグローバル空間に書く
def main():
    n = int_input()
    a = int_list()
    b = int_list()

    ans = 0
    for V in permutations(a):
        for W in permutations(b):
            a_win = 0; b_win = 0
            for i in range(n):
                if V[i] > W[i]:
                    a_win += 1
                if V[i] < W[i]:
                    b_win += 1
            if a_win > b_win:
                ans += 1
    print(ans / (factorial(n) ** 2))

if __name__ == '__main__':
    main()
0