結果

問題 No.3758 Fan Meeting
コンテスト
ユーザー atcoder8
提出日時 2026-10-09 23:35:07
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 16 ms / 2,000 ms
+ 835µs
コード長 679 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 991 ms
コンパイル使用メモリ 197,396 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-10-09 23:35:25
合計ジャッジ時間 4,717 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::cmp::Reverse;

use proconio::input;

fn main() {
    input! {
        (n, s): (usize, usize),
        mut aa: [usize; n],
    }

    aa.sort_unstable_by_key(|&a| Reverse(a));

    let is_ok = |x: usize| {
        let mut curr = 0;
        let mut sum = 0;
        while curr < n && sum + aa[curr] < s {
            sum += aa[curr];
            curr += x;
        }

        curr >= n || aa[curr] <= x
    };

    let mut ok = *aa.iter().max().unwrap();
    let mut ng = 0_usize;
    while ok.abs_diff(ng) > 1 {
        let mid = (ok + ng) / 2;
        if is_ok(mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    println!("{ok}");
}
0