Submission #68688300


Source Code Expand

from itertools import product
from functools import cache
from collections import defaultdict
from fractions import Fraction as F
A=list(map(int,input().split()))

# 値が0-5の大きさnの多重集合を列挙
deme=[defaultdict(lambda: F(0,1)) for _ in range(6)]
for n in range(1,6):
  deno=6**n
  for idxs in product(range(6),repeat=n):
    deme[n][tuple(sorted(idxs))]+=F(1,deno)

@cache
def f(rest_turn, keep_idxs):
  # rest_turn ターン残って、キープしてる出目のindexの集合がkeep_idxsのときの最終的な得点の期待値
  if len(keep_idxs)==5:
    count = defaultdict(int)
    for idx in keep_idxs: count[A[idx]] += 1
    return max(k*v for k,v in count.items())
  rest_dice = 5-len(keep_idxs)
  ans = 0
  for deme_idxs in product(range(6), repeat=rest_dice):
    prob = F(1, 6**rest_dice)
    M=0
    for keep in (range(1<<rest_dice) if rest_turn!=1 else [(1<<rest_dice)-1]):
      M=max(M,f(rest_turn-1, tuple(sorted(keep_idxs+tuple(idx for i,idx in enumerate(deme_idxs) if (keep>>i)&1)))))
    ans+=M*prob
  return ans

print(f"{float(f(3,tuple())):.10f}")

Submission Info

Submission Time
Task E - Yacht
User kyopro_friends
Language Python (PyPy 3.10-v7.3.12)
Score 475
Code Size 1124 Byte
Status AC
Exec Time 882 ms
Memory 96800 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 3
AC × 22
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 841 ms 95856 KiB
random_02.txt AC 867 ms 93172 KiB
random_03.txt AC 850 ms 95764 KiB
random_04.txt AC 860 ms 95504 KiB
random_05.txt AC 872 ms 94752 KiB
random_06.txt AC 871 ms 96072 KiB
random_07.txt AC 856 ms 94504 KiB
random_08.txt AC 860 ms 94364 KiB
random_09.txt AC 874 ms 95128 KiB
random_10.txt AC 874 ms 95004 KiB
random_11.txt AC 865 ms 94660 KiB
random_12.txt AC 882 ms 96800 KiB
random_13.txt AC 853 ms 95720 KiB
random_14.txt AC 840 ms 94744 KiB
random_15.txt AC 855 ms 95680 KiB
random_16.txt AC 788 ms 95864 KiB
random_17.txt AC 836 ms 93340 KiB
random_18.txt AC 850 ms 96232 KiB
random_19.txt AC 864 ms 93060 KiB
sample_01.txt AC 877 ms 95756 KiB
sample_02.txt AC 809 ms 95352 KiB
sample_03.txt AC 853 ms 93524 KiB