結果
問題 | No.9 モンスターのレベル上げ |
ユーザー |
|
提出日時 | 2024-07-30 17:33:10 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 489 ms / 5,000 ms |
コード長 | 1,053 bytes |
コンパイル時間 | 12,806 ms |
コンパイル使用メモリ | 403,056 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-30 17:33:31 |
合計ジャッジ時間 | 18,486 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
warning: unused imports: `HashMap`, `HashSet` --> src/main.rs:1:34 | 1 | use std::collections::{BTreeSet, HashMap, HashSet, VecDeque}; | ^^^^^^^ ^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused import: `proconio::marker::Chars` --> src/main.rs:3:5 | 3 | use proconio::marker::Chars; | ^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
use std::collections::{BTreeSet, HashMap, HashSet, VecDeque}; use proconio::marker::Chars; fn main() { proconio::input! { n: u32, mut a: [i32;n], b: [i32;n], } let mut min_b = i32::MAX; let mut b = VecDeque::from_iter(b); for _ in 0..n { #[derive(PartialEq, Eq, PartialOrd, Ord)] struct Mons { level: i32, battle: i32, id: usize, } let mut bts = a .iter() .copied() .enumerate() .map(|(i, l)| Mons { level: l, battle: 0, id: i, }) .collect::<BTreeSet<_>>(); for b in b.iter() { let mut a = bts.pop_first().unwrap(); a.level += b / 2; a.battle += 1; bts.insert(a); } min_b = std::cmp::min(min_b, bts.iter().map(|b| b.battle).max().unwrap()); let temp = b.pop_front().unwrap(); b.push_back(temp); } println!("{min_b}"); }