結果

問題 No.3281 Pacific White-sided Dolphin vs Monster
コンテスト
ユーザー flippergo
提出日時 2026-10-12 14:40:37
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 812 ms / 2,000 ms
+ 470µs
コード長 490 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 65 ms
コンパイル使用メモリ 81,508 KB
実行使用メモリ 101,972 KB
最終ジャッジ日時 2026-10-12 14:41:02
合計ジャッジ時間 14,763 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import heapq
N = int(input())
H = sorted(list(map(int,input().split())),reverse=True)
hmax = H[0]
kmax = 0
while 1<<kmax<=hmax:
    kmax += 1
low = N-1
high = N+kmax
while high-low>1:
    mid = (high+low)//2
    heap = [-H[i] for i in range(N)]
    for i in range(mid-1,-1,-1):
        if len(heap)==0:break
        h = -heapq.heappop(heap)
        h -= 1<<i
        if h>0:
            heapq.heappush(heap,-h)
    if len(heap)==0:
        high = mid
    else:
        low = mid
print(high)
0