結果

問題 No.3281 Pacific White-sided Dolphin vs Monster
コンテスト
ユーザー flippergo
提出日時 2026-10-12 11:31:01
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 1,084 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 82 ms
コンパイル使用メモリ 81,748 KB
実行使用メモリ 301,872 KB
最終ジャッジ日時 2026-10-12 11:31:52
合計ジャッジ時間 30,342 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49 WA * 1 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import heapq
N = int(input())
heap = sorted(list(map(int,input().split())))
hmax = heap[-1]
kmax = 0
while 1<<kmax<=hmax:
    kmax += 1
low = N-1
high = N+kmax
while high-low>1:
    heap0 = heap[:]
    M0 = len(heap0)
    mid = (high+low)//2
    cnt = 0
    for i in range(mid):
        if M0==0 or cnt>=kmax:break
        cnt += 1
        heap1 = []
        M1 = 0
        M2 = M0
        for _ in range(M2):
            h = heapq.heappop(heap0)
            M0 -= 1
            if h>>i & 1:
                h -= 1<<i
                if h>0:
                    heapq.heappush(heap1,h)
                    M1 += 1
                break
            if h%(1<<i)>0:
                h -= 1<<i
                if h>0:
                    heapq.heappush(heap1,h)
                    M1 += 1
                break
            heapq.heappush(heap1,h)
            M1 += 1
        heap0 += heap1
        M0 += M1
        heapq.heapify(heap0)
    if M0==0:
        high = mid
    else:
        cnt += M0
        if cnt<=mid:
            high = mid
        else:
            low = mid
print(high)
0