結果

問題 No.9 モンスターのレベル上げ
ユーザー tonyu0tonyu0
提出日時 2019-12-15 21:29:46
言語 Rust
(1.77.0)
結果
AC  
実行時間 220 ms / 5,000 ms
コード長 1,001 bytes
コンパイル時間 866 ms
コンパイル使用メモリ 149,756 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-15 15:43:54
合計ジャッジ時間 3,692 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 218 ms
4,384 KB
testcase_03 AC 167 ms
4,380 KB
testcase_04 AC 83 ms
4,384 KB
testcase_05 AC 58 ms
4,380 KB
testcase_06 AC 19 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 26 ms
4,380 KB
testcase_09 AC 213 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 181 ms
4,380 KB
testcase_12 AC 203 ms
4,384 KB
testcase_13 AC 132 ms
4,380 KB
testcase_14 AC 220 ms
4,380 KB
testcase_15 AC 192 ms
4,384 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 117 ms
4,380 KB
testcase_18 AC 96 ms
4,380 KB
testcase_19 AC 3 ms
4,380 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