結果
| 問題 |
No.295 hel__world
|
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2021-01-02 10:54:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 970 bytes |
| コンパイル時間 | 676 ms |
| コンパイル使用メモリ | 82,100 KB |
| 実行使用メモリ | 80,768 KB |
| 最終ジャッジ日時 | 2024-10-12 00:37:39 |
| 合計ジャッジ時間 | 8,666 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 WA * 4 TLE * 1 -- * 41 |
ソースコード
*a, = map(int,input().split())
d = {}
t = input()+"Z"
ren = -1
cnt = 0
now = "A"
for i in t:
if i == now:
cnt += 1
else:
if now in d: d[now].append(cnt)
else: d[now] = [cnt]
now = i
cnt = 1
ren += 1
V = [0]*26
from heapq import *
for i,ai in enumerate(a):
s = chr(i+97)
if ai==0 or (ai != 0 and s not in d): continue
ds = d[s]
v = ai - sum(ds)
V[i] = v
if v < 0:
print(0)
exit()
ans = 1
MAX = 1<<62
for i,ai in enumerate(a):
s = chr(i+97)
if ai==0 or (ai != 0 and s not in d): continue
v = V[i]
if v==0:
continue
# 倍率、先頭、長さ
q = [(-(i+1.0),i,i) for i in d[s]]
heapify(q)
#print(chr(i+97),v,d[chr(i+97)])
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))
if ans > MAX:
print("hel")
exit()
print(ans)
convexineq