結果

問題 No.3758 Fan Meeting
コンテスト
ユーザー himueu
提出日時 2026-10-15 23:21:39
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 842 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,442 ms
コンパイル使用メモリ 186,716 KB
実行使用メモリ 9,796 KB
最終ジャッジ日時 2026-10-15 23:21:59
合計ジャッジ時間 8,800 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
    using namespace std;
    int n, s;
    cin >> n >> s;
    long long tot = 0;
    vector<int> a(n);
    for (auto &e : a) {
        cin >> e;
        tot += e;
    }
    sort(a.rbegin(), a.rend());

    auto pred = [&](long long m) -> bool {
        vector<int> large;
        int res = 0;
        for (auto e : a) {
            if (e <= m) {
                res++;
            } else {
                if (large.size() % m == 0) { res += e + 1; } 
                large.push_back(e);
            }
        }
        return res <= s;
    };

    long long ok = tot, ng = 0;
    while (ok - ng > 1) {
        long long mid = (ok + ng) / 2;
        if (pred(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok << endl;
}
0