結果

問題 No.3281 Pacific White-sided Dolphin vs Monster
ユーザー GOTKAKO
提出日時 2025-09-26 23:47:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 759 bytes
コンパイル時間 2,203 ms
コンパイル使用メモリ 204,504 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-26 23:47:21
合計ジャッジ時間 4,423 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N; cin >> N;
    vector<long long> H(N);
    for(auto &h : H) cin >> h;
    sort(H.rbegin(),H.rend());

    long long low = 0,high = N+100;
    while(high-low > 1){
        long long mid = (high+low)/2;
        long long x = mid-1;
        priority_queue<long long> Q;
        for(auto h : H){
            if(x < 60) Q.push(h);
            else x--;
        }
        while(Q.size()){
            if(x == -1){x--; break;}
            long long h = Q.top(); Q.pop();
            h -= 1LL<<x,x--;
            if(h > 0) Q.push(h);
        }
        if(x == -2) low = mid;
        else high = mid;
    }
    cout << high << endl;
}
0