結果

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

ソースコード

diff #
raw source code

use proconio::{fastout, input};

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

    a.sort_unstable();
    a.reverse();
    let mut ok = a.iter().sum::<usize>();
    let mut ng = 0;
    while (ok - ng) > 1 {
        let mid = (ok + ng) / 2;

        let mut x = 0;
        for i in (0..n).step_by(mid) {
            if a[i] <= mid {
                break;
            }

            x += a[i];
        }

        if x < s {
            ok = mid;
        } else {
            ng = mid;
        }
    }

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