結果

問題 No.295 hel__world
ユーザー convexineqconvexineq
提出日時 2021-01-02 11:45:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,798 ms / 5,000 ms
コード長 1,183 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 82,516 KB
実行使用メモリ 152,108 KB
最終ジャッジ日時 2024-04-20 06:27:35
合計ジャッジ時間 12,367 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,948 KB
testcase_01 AC 34 ms
53,540 KB
testcase_02 AC 42 ms
54,420 KB
testcase_03 AC 40 ms
53,776 KB
testcase_04 AC 35 ms
53,908 KB
testcase_05 AC 42 ms
54,504 KB
testcase_06 AC 33 ms
53,364 KB
testcase_07 AC 41 ms
53,348 KB
testcase_08 AC 37 ms
54,216 KB
testcase_09 AC 40 ms
53,784 KB
testcase_10 AC 42 ms
52,992 KB
testcase_11 AC 35 ms
53,536 KB
testcase_12 AC 35 ms
54,192 KB
testcase_13 AC 36 ms
54,604 KB
testcase_14 AC 36 ms
53,400 KB
testcase_15 AC 36 ms
54,124 KB
testcase_16 AC 34 ms
53,260 KB
testcase_17 AC 37 ms
54,400 KB
testcase_18 AC 34 ms
53,168 KB
testcase_19 AC 35 ms
54,204 KB
testcase_20 AC 35 ms
53,768 KB
testcase_21 AC 37 ms
54,300 KB
testcase_22 AC 37 ms
54,052 KB
testcase_23 AC 36 ms
54,552 KB
testcase_24 AC 36 ms
53,888 KB
testcase_25 AC 53 ms
65,448 KB
testcase_26 AC 46 ms
60,364 KB
testcase_27 AC 39 ms
53,072 KB
testcase_28 AC 1,788 ms
76,548 KB
testcase_29 AC 1,798 ms
76,504 KB
testcase_30 AC 36 ms
54,460 KB
testcase_31 AC 35 ms
53,260 KB
testcase_32 AC 300 ms
148,888 KB
testcase_33 AC 275 ms
144,804 KB
testcase_34 AC 303 ms
152,108 KB
testcase_35 AC 38 ms
54,452 KB
testcase_36 AC 34 ms
53,308 KB
testcase_37 AC 37 ms
54,132 KB
testcase_38 AC 36 ms
53,864 KB
testcase_39 AC 37 ms
53,484 KB
testcase_40 AC 41 ms
54,216 KB
testcase_41 AC 41 ms
54,632 KB
testcase_42 AC 40 ms
52,684 KB
testcase_43 AC 1,012 ms
76,300 KB
testcase_44 AC 1,038 ms
76,740 KB
testcase_45 AC 1,023 ms
76,384 KB
testcase_46 AC 41 ms
54,268 KB
testcase_47 AC 34 ms
53,936 KB
testcase_48 AC 39 ms
54,184 KB
testcase_49 AC 37 ms
53,732 KB
testcase_50 AC 61 ms
67,636 KB
testcase_51 AC 365 ms
76,592 KB
testcase_52 AC 127 ms
76,392 KB
testcase_53 AC 71 ms
79,388 KB
testcase_54 AC 75 ms
79,368 KB
testcase_55 AC 71 ms
79,188 KB
testcase_56 AC 71 ms
79,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import groupby
*a, = map(int,input().split())
d = {}
t = input()+"Z"
for k,v in groupby(t):
    v = "".join(v)
    if k in d: d[k].append(len(v))
    else: d[k] = [len(v)]
V = [0]*26
from heapq import *
for i,ai in enumerate(a):
    s = chr(i+97)
    if s not in d: continue
    v = ai - sum(d[s])
    V[i] = v
    if v < 0:
        print(0)
        exit()

def hel(ans):
    if ans >= MAX:
        print("hel")
        exit()

ans = 1
MAX = 1<<62
for i,ai in enumerate(a):
    s = chr(i+97)
    if s not in d: continue
    v = V[i]
    if v==0: continue
    q = [(-(i+1.0),i,i) for i in d[s]] # 倍率、先頭、長さ
    if len(q) == 1:
        for i in range(q[0][-1]):
            ans *= ai-q[0][-1]+i+1
            ans //= i+1
            hel(ans)
        continue
    if len(q) == 2 == sum(d[s]):
        x = ai//2
        for aa in [x,ai-x]:
            ans *= aa
            hel(ans)
        continue
    if (v//len(q)) > (MAX+10)**(1/len(q)) or (v > 64 and len(q) > 64):
        hel(MAX)
    heapify(q)
    for _ in range(v):
        __,x,y = heappop(q)
        ans = ans*(y+1)//(y-x+1)
        heappush(q,(-(y+2)/(y+2-x),x,y+1))
        hel(ans)
print(ans)
0