結果

問題 No.3297 Bake Cookies
コンテスト
ユーザー hanba-gu1
提出日時 2025-08-23 23:07:41
言語 Rust
(1.99.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 985 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 13,245 ms
コンパイル使用メモリ 182,976 KB
実行使用メモリ 9,772 KB
最終ジャッジ日時 2026-10-17 00:48:50
合計ジャッジ時間 5,034 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::collections::BTreeSet;

use proconio::{input, marker::Usize1};

fn main() {
    input! {
        n: usize, m: usize, t: i64,
        a: [Usize1; m],
    }

    let mut a_counts = vec![0i64; n];
    for &a in &a {
        a_counts[a] += 1;
    }
    a_counts.sort();

    let mut a_counts = a_counts.into_iter().map(|a| (a, a)).collect::<BTreeSet<_>>();
    let mut ans = a_counts.last().unwrap().0;
    loop {
        let min = *a_counts.first().unwrap();
        let max = *a_counts.last().unwrap();
        if max.1 == 0 {
            println!("{}", ans);
            break;
        } else {
            if min.0 + t <= ans {
                a_counts.pop_first();
                a_counts.insert((min.0 + t, min.0));
                a_counts.pop_last();
                a_counts.insert((max.0 - 1, max.1 - 1));
                ans = a_counts.last().unwrap().0;
            } else {
                println!("{}", ans);
                break;
            }
        }
    }
}
0