結果
| 問題 |
No.3297 Bake Cookies
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-23 23:07:41 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 985 bytes |
| コンパイル時間 | 11,766 ms |
| コンパイル使用メモリ | 399,084 KB |
| 実行使用メモリ | 9,576 KB |
| 最終ジャッジ日時 | 2025-08-23 23:07:58 |
| 合計ジャッジ時間 | 14,937 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
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;
}
}
}
}