結果

問題 No.3281 Pacific White-sided Dolphin vs Monster
ユーザー timi
提出日時 2025-09-26 21:39:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 907 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 145,784 KB
最終ジャッジ日時 2025-09-26 21:39:55
合計ジャッジ時間 15,638 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#N,X,Q=map(int, input().split())

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

ng,ok=0,100+N+1
import heapq
while ok-ng>1:
  mid=(ok+ng)//2 
  C=[1]
  for i in range(mid-1):
    C.append(C[-1]*2)
    if C[-1]>10**18:
      C[-1]=10**18
      
  E=[]
  for h in H:
    heapq.heappush(E,-h)
  for c in C[::-1]:
    d=heapq.heappop(E)
    d*=-1 
    e=d-c 
    if e>0:
      heapq.heappush(E,-e)
    if len(E)==0:
      break
      
  if len(E)==0:
    ok=mid 
  else:
    ng=mid
print(ok)
0