結果
| 問題 |
No.295 hel__world
|
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2021-01-02 12:17:36 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 968 bytes |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 82,444 KB |
| 実行使用メモリ | 84,328 KB |
| 最終ジャッジ日時 | 2024-10-12 02:14:23 |
| 合計ジャッジ時間 | 10,509 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 TLE * 1 -- * 27 |
ソースコード
from itertools import groupby
from collections import defaultdict
from heapq import *
*a, = map(int,input().split())
d = defaultdict(list)
t = input()
for k,v in groupby(t):
d[k].append(len(list(v)))
def get(ai,lst):
if not lst: return 1
res = 1
v = ai - sum(lst)
if v < 0: return 0
lst = sorted(lst,reverse=True)[:65]
q = [(-(i+1.0),i,i) for i in lst] # 倍率、先頭、長さ
if len(q) == 1:
c = lst[0]
for i in range(min(c,ai-c)):
res *= ai-i
res //= i+1
if res >= MAX: return MAX
return res
if len(q) == 2 == sum(lst):
return min(ai//2*((ai+1)//2),MAX)
heapify(q)
for _ in range(v):
__,x,y = heappop(q)
res = res*(y+1)//(y-x+1)
heappush(q,(-(y+2)/(y+2-x),x,y+1))
if res >= MAX: return res
return res
ans = 1
MAX = 1<<62
for i,ai in enumerate(a):
ans *= get(ai,d[chr(i+97)])
print(ans if ans < MAX else "hel")
convexineq