結果

問題 No.3758 Fan Meeting
コンテスト
ユーザー ei1333333
提出日時 2026-10-09 15:46:58
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 34 ms / 2,000 ms
+ 997µs
コード長 687 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,236 ms
コンパイル使用メモリ 361,272 KB
実行使用メモリ 9,916 KB
最終ジャッジ日時 2026-10-09 20:56:21
合計ジャッジ時間 6,435 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    int64 s;
    cin >> n >> s;
    vector<int64> a(n);
    for (auto& x : a) cin >> x;
    sort(a.rbegin(), a.rend());
    auto feasible = [&](int64 t) {
        int64 required = 0;
        for (int64 i = 0; i < n && a[i] > t; i += t) {
            required += a[i];
            if (required >= s) return false;
        }
        return true;
    };
    int64 lo = 0, hi = a[0];
    while (hi - lo > 1) {
        int64 mid = lo + (hi - lo) / 2;
        if (feasible(mid)) hi = mid;
        else lo = mid;
    }
    cout << hi << '\n';
}
0