結果

問題 No.9 モンスターのレベル上げ
ユーザー tonyu0tonyu0
提出日時 2019-12-15 21:29:46
言語 Rust
(1.59.0)
結果
AC  
実行時間 202 ms / 5,000 ms
コード長 1,001 bytes
コンパイル時間 690 ms
使用メモリ 2,060 KB
最終ジャッジ日時 2023-02-03 20:25:52
合計ジャッジ時間 3,513 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 1 ms
1,888 KB
testcase_01 AC 1 ms
1,872 KB
testcase_02 AC 202 ms
1,864 KB
testcase_03 AC 162 ms
1,944 KB
testcase_04 AC 80 ms
1,872 KB
testcase_05 AC 56 ms
1,868 KB
testcase_06 AC 18 ms
1,976 KB
testcase_07 AC 1 ms
1,904 KB
testcase_08 AC 24 ms
1,924 KB
testcase_09 AC 198 ms
1,872 KB
testcase_10 AC 1 ms
1,872 KB
testcase_11 AC 132 ms
1,980 KB
testcase_12 AC 146 ms
2,048 KB
testcase_13 AC 138 ms
1,968 KB
testcase_14 AC 200 ms
2,060 KB
testcase_15 AC 181 ms
1,972 KB
testcase_16 AC 4 ms
1,920 KB
testcase_17 AC 112 ms
2,020 KB
testcase_18 AC 90 ms
2,044 KB
testcase_19 AC 3 ms
1,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<i32> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let b: Vec<i32> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut ans: i32 = 2000;
    for i in 0..n {
        let mut tmp: i32 = 0;
        let mut pq = std::collections::BinaryHeap::new();
        for j in 0..n {
            pq.push((-a[j], 0))
        }
        for j in 0..n {
            let (mut level, mut count) = pq.pop().unwrap();
            level *= -1;
            count *= -1;
            level += b[(i + j) % n] / 2;
            count += 1;
            tmp = std::cmp::max(tmp, count);
            pq.push((-level, -count));
        }
        ans = std::cmp::min(ans, tmp);
    }
    println!("{}", ans);
}
0