結果
| 問題 | 
                            No.3297 Bake Cookies
                             | 
                    
| コンテスト | |
| ユーザー | 
                             EvbCFfp1XB
                         | 
                    
| 提出日時 | 2025-10-05 17:48:28 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 25 ms / 2,000 ms | 
| コード長 | 849 bytes | 
| コンパイル時間 | 29,962 ms | 
| コンパイル使用メモリ | 396,980 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-10-05 17:49:01 | 
| 合計ジャッジ時間 | 14,509 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 27 | 
ソースコード
use proconio::{input, marker::Usize1};
fn main() {
    input! {
        n: usize,
        m: usize,
        t: i64,
        a: [Usize1; m],
    }
    let mut sum = vec![0; n];
    a.iter().for_each(|&i| sum[i] += 1);
    println!(
        "{}",
        binary_search(
            |x| {
                sum.iter().fold(0, |time, &s| {
                    if s >= x {
                        time + s - x
                    } else {
                        time - (x - s) / t
                    }
                }) <= 0
            },
            m as i64,
            0
        )
    );
}
fn binary_search<F>(f: F, mut ok: i64, mut ng: i64) -> i64
where
    F: Fn(i64) -> bool,
{
    while (ok - ng).abs() > 1 {
        let x = (ok + ng) / 2;
        if f(x) {
            ok = x;
        } else {
            ng = x;
        }
    }
    ok
}
            
            
            
        
            
EvbCFfp1XB