結果

問題 No.3281 Pacific White-sided Dolphin vs Monster
ユーザー nikoro256
提出日時 2025-09-26 23:25:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 847 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 82,912 KB
実行使用メモリ 101,444 KB
最終ジャッジ日時 2025-09-26 23:25:43
合計ジャッジ時間 15,436 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

def binary_search(f):
    left,right=0,10**5 + 80
    while right-left>1:
        mid=(right+left)//2
        if f(mid):
            right=mid
        else:
            left=mid
    return right

def f(x):
    hq = [-h for h in H]
    heapq.heapify(hq)
    for i in range(x-1,-1,-1):
        if len(hq) == 0:
            break
        if i>=60:
            t = 2**60
        else:
            t = 2**i
        p = heapq.heappop(hq)
        p += t
        if p<0:
            heapq.heappush(hq, p)
    if len(hq) == 0:
        return True
    return False

import heapq
N=int(input())
H=list(map(int,input().split()))
print(binary_search(f))
0