結果

問題 No.9 モンスターのレベル上げ
ユーザー phsplsphspls
提出日時 2022-08-30 01:09:31
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,052 bytes
コンパイル時間 1,282 ms
コンパイル使用メモリ 162,176 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 13:35:57
合計ジャッジ時間 3,483 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 121 ms
5,376 KB
testcase_12 AC 152 ms
5,376 KB
testcase_13 AC 117 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::{collections::BinaryHeap, cmp::Reverse};


fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut a = String::new();
    std::io::stdin().read_line(&mut a).ok();
    let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let mut b = String::new();
    std::io::stdin().read_line(&mut b).ok();
    let b: Vec<usize> = b.trim().split_whitespace().map(|s| s.parse::<usize>().unwrap() / 2).collect();

    let a = a.into_iter().map(|v| (Reverse(v), Reverse(0))).collect::<BinaryHeap<(Reverse<usize>, Reverse<usize>)>>();
    let mut result = 0usize;
    for i in 0..n {
        let mut pque = a.clone().to_owned();
        for j in 0..n {
            let (level, cnt) = pque.pop().unwrap();
            let bidx = if i + j >= n { i + j - n } else { i + j };
            pque.push((Reverse(level.0 + b[bidx]), Reverse(cnt.0 + 1)));
            result = result.max(cnt.0 + 1);
        }
    }
    println!("{}", result);
}
0