結果
| 問題 |
No.9 モンスターのレベル上げ
|
| ユーザー |
|
| 提出日時 | 2019-12-15 21:29:46 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 201 ms / 5,000 ms |
| コード長 | 1,001 bytes |
| コンパイル時間 | 12,922 ms |
| コンパイル使用メモリ | 378,876 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 18:21:26 |
| 合計ジャッジ時間 | 15,703 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
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);
}