結果

問題 No.3281 Pacific White-sided Dolphin vs Monster
コンテスト
ユーザー ゆかり
提出日時 2025-11-07 16:35:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,020 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 84,144 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-11-07 16:35:45
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using LL = long long;

int main() {
    int N;
    std::cin >> N;
    std::vector<LL> H(N);
    for (auto& x : H) {
        std::cin >> x;
    }
    std::sort(H.begin(), H.end());
    auto check = [&](int x) -> bool {
        std::priority_queue<LL> q;
        for (int i = 0; i < N - std::max(x - 60, 0); i++) {
            q.emplace(H[i]);
        }
        x = std::min(x, 60);
        for (; x >= 0; x--) {
            if (q.empty()) {
                break;
            }
            auto t = q.top();
            q.pop();
            t -= (1LL << x);
            if (t > 0) {
                q.emplace(t);
            }
        }
        return q.empty();
    };
    int left = N;
    int right = N + 60;
    while (left < right) {
        int mid = (left + right) / 2;
        if (check(mid)) {
            right = mid;
        } else {
            left = mid + 1;
        }
    }
    std::cout << left + 1 << std::endl;
    return 0;
}
0