結果

問題 No.9 モンスターのレベル上げ
ユーザー ooaiu
提出日時 2024-11-13 16:45:23
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 234 ms / 5,000 ms
コード長 721 bytes
コンパイル時間 13,700 ms
コンパイル使用メモリ 402,220 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-13 16:45:43
合計ジャッジ時間 17,439 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
        b: [usize; n],
    }
    let mut ans = usize::MAX;
    for i in 0..n {
        let mut pq = BinaryHeap::new();
        for j in 0..n {
            pq.push(Reverse((a[j], 0)));
        }
        let mut cur = 0;
        for jj in 0..n {
            let j = (i + jj) % n;
            if let Some(Reverse((mut x, mut y))) = pq.pop() {
                x += b[j]/2;
                y += 1;
                cur = cur.max(y);
                pq.push(Reverse((x, y)));
            }
        }
        if ans > cur {
            ans = cur;
        }
    }
    println!("{}", ans);
}
0