結果
問題 | No.9 モンスターのレベル上げ |
ユーザー | hitoyozake |
提出日時 | 2018-06-27 06:27:58 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,697 bytes |
コンパイル時間 | 14,065 ms |
コンパイル使用メモリ | 400,056 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-30 23:07:09 |
合計ジャッジ時間 | 16,474 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 258 ms
6,944 KB |
testcase_03 | WA | - |
testcase_04 | AC | 100 ms
6,944 KB |
testcase_05 | WA | - |
testcase_06 | AC | 21 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 36 ms
6,940 KB |
testcase_09 | AC | 255 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | WA | - |
testcase_12 | AC | 213 ms
6,944 KB |
testcase_13 | AC | 128 ms
6,940 KB |
testcase_14 | AC | 252 ms
6,940 KB |
testcase_15 | WA | - |
testcase_16 | AC | 5 ms
6,948 KB |
testcase_17 | AC | 153 ms
6,944 KB |
testcase_18 | AC | 146 ms
6,944 KB |
testcase_19 | WA | - |
コンパイルメッセージ
warning: unused variable: `r` --> src/main.rs:11:9 | 11 | let r = std::io::stdin().read_line(& mut buf); | ^ help: if this is intentional, prefix it with an underscore: `_r` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `integer_length` --> src/main.rs:69:16 | 69 | let Inches(integer_length) = length; | ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_integer_length` warning: unused variable: `il` --> src/main.rs:70:9 | 70 | let il:Inches = Inches(20); | ^^ help: if this is intentional, prefix it with an underscore: `_il` warning: unused variable: `party` --> src/main.rs:79:13 | 79 | let mut party: Vec<Monster> = Vec::new(); | ^^^^^ help: if this is intentional, prefix it with an underscore: `_party` warning: variable does not need to be mutable --> src/main.rs:79:9 | 79 | let mut party: Vec<Monster> = Vec::new(); | ----^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default warning: struct `Unit` is never constructed --> src/main.rs:3:8 | 3 | struct Unit{ | ^^^^ | = note: `#[warn(dead_code)]` on by default
ソースコード
use std::collections::BinaryHeap; struct Unit{ level: i32, count: i32 } fn get_line()->String{ let mut buf = String::new(); let r = std::io::stdin().read_line(& mut buf); buf } use std::cmp::Ordering; #[derive(Eq)] struct Monster{ level: i32, count: i32 } impl Clone for Monster{ fn clone(&self)->Monster{ Monster{level:self.level, count:self.count} } } impl PartialOrd for Monster{ fn partial_cmp(&self, other: &Monster)->Option<Ordering>{ if self.level < other.level { Some(Ordering::Greater) } else if self.count <= other.count { Some(Ordering::Greater) } else{ Some(Ordering::Less) } } } impl PartialEq for Monster{ fn eq(&self, other: &Monster)->bool{ (self.level, self.count) == (other.level, other.count) } } // BinaryHeapのために実装 impl Ord for Monster{ fn cmp(&self, other: &Monster)->Ordering{ (self.level, self.count).cmp(&(other.level, other.count)) //(self.level, self.count).cmp(&(other.level, other.count)) } } fn main() { struct Inches(i32); let length = Inches(10); let Inches(integer_length) = length; let il:Inches = Inches(20); let mut que:BinaryHeap<Monster>= BinaryHeap::new(); let n: i32 = get_line().trim().parse::<i32>().unwrap(); let tmp = String::from(get_line().trim()); let sv:Vec<&str> = tmp.split(" ").collect(); let mut party: Vec<Monster> = Vec::new(); for i in sv{ que.push(Monster{ level:i.parse::<i32>().unwrap(), count: 0}); } let tmp = String::from(get_line().trim()); let sv:Vec<&str> = tmp.split(" ").collect(); let mut enem_levels: Vec<i32> = Vec::new(); for i in sv{ enem_levels.push(i.parse::<i32>().unwrap()/2); } let mut max_count_min = 1000000; for i in 0..n{ let mut pt = que.clone(); let mut max_count = 0; //popされた時の値をうまくなるように調整が必要そう for j in 0..n{ let mut selected = pt.pop().unwrap(); //println!("selected . l:{}, c:{}", selected.level, selected.count); selected.count+=1; let usz = ((i+j)%n) as u32; selected.level += enem_levels[usz as usize]; max_count = std::cmp::max(max_count, selected.count); //println!("r . l:{}, c:{}", selected.level, selected.count); pt.push(selected); } max_count_min = std::cmp::min(max_count_min, max_count); } println!("{}", max_count_min); }