結果

問題 No.9 モンスターのレベル上げ
ユーザー tabataba
提出日時 2024-07-30 17:33:10
言語 Rust
(1.77.0)
結果
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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 489 ms
6,944 KB
testcase_03 AC 400 ms
6,940 KB
testcase_04 AC 203 ms
6,940 KB
testcase_05 AC 135 ms
6,944 KB
testcase_06 AC 45 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 57 ms
6,944 KB
testcase_09 AC 465 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 379 ms
6,940 KB
testcase_12 AC 154 ms
6,940 KB
testcase_13 AC 360 ms
6,944 KB
testcase_14 AC 488 ms
6,940 KB
testcase_15 AC 423 ms
6,940 KB
testcase_16 AC 6 ms
6,940 KB
testcase_17 AC 270 ms
6,944 KB
testcase_18 AC 230 ms
6,940 KB
testcase_19 AC 4 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
  |     ^^^^^^^^^^^^^^^^^^^^^^^

ソースコード

diff #

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}");
}
0