結果

問題 No.9 モンスターのレベル上げ
ユーザー hitoyozakehitoyozake
提出日時 2018-06-27 06:29:26
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 2,696 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 156,512 KB
実行使用メモリ 5,196 KB
最終ジャッジ日時 2023-09-13 14:23:43
合計ジャッジ時間 4,833 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 148 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 18 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 122 ms
4,380 KB
testcase_12 AC 123 ms
4,376 KB
testcase_13 AC 115 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 3 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `r`
  --> 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`
  --> 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`
  --> 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`
  --> 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
  --> 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
 --> Main.rs:3:8
  |
3 | struct Unit{
  |        ^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 6 warnings emitted

ソースコード

diff #

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);

}
0