結果

問題 No.3281 Pacific White-sided Dolphin vs Monster
ユーザー titia
提出日時 2025-09-29 22:18:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 694 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 82,844 KB
実行使用メモリ 109,392 KB
最終ジャッジ日時 2025-10-03 17:39:03
合計ジャッジ時間 13,346 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from heapq import heappop,heappush

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

A.sort(reverse=True)

OK=10**5
NG=0

while OK>NG+1:
    mid=(OK+NG)//2

    H=[]
    for a in A:
        heappush(H,-a)

    for i in range(mid-1,-1,-1):
        if i>=65:
            d=10**18
        else:
            d=(1<<i)

        x=-heappop(H)

        x-=d

        if x>0:
            heappush(H,-x)

        if len(H)==0:
            break

    if len(H)==0:
        OK=mid
    else:
        NG=mid

print(OK)
            
        
0