結果

問題 No.3221 Count Turns
ユーザー timi
提出日時 2025-08-03 13:05:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,005 ms / 2,000 ms
コード長 669 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 82,708 KB
実行使用メモリ 125,388 KB
最終ジャッジ日時 2025-08-03 13:05:59
合計ジャッジ時間 18,943 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

N,H,T=map(int, input().split())
A=list(map(int, input().split()))

C=[]
import heapq
ans=[0]*N
for i in range(N):
  a=A[i]
  t=(H-1)//a+1
  heapq.heappush(C,(t,t*a,i))

from collections import deque
d=deque()
for j in range(T):
  if len(d)==0:
    E=[]
    t,ta,i=heapq.heappop(C)
    E.append((t,ta,i))
    p=t
    while C:
      t,ta,i=heapq.heappop(C)
      if p!=t:
        heapq.heappush(C,(t,ta,i))
        break
      else:
        E.append((t,ta,i))
    E=sorted(E,key=lambda x: x[2])
    E=sorted(E,reverse=True,key=lambda x: x[1])
    for e in E:
      d.append(e)

  t,ta,i=d.popleft()
  ans[i]+=1
  p=(H-1)//A[i]+1
  heapq.heappush(C,(p+t,ta,i))
print(*ans)
0