Submission #1547289


Source Code Expand

#[allow(dead_code)]
#[allow(unused_macros)]
#[macro_use]
mod procon {
    macro_rules! list_to_tuple {
        ($ls:expr, $($x:ident),*) => {
            let mut i = 0;
            $(
                let $x = $ls[i];
                println!("let {} = ls[{}] (={})", stringify!($x), i, $ls[i]);
                i += 1;
            )*
            assert!(i == $ls.len());
        };
    }

    use std::io;

    //
    // stdin helpers
    //

    pub fn read_item<T>() -> T
        where T : super::std::str::FromStr,
              <T as super::std::str::FromStr>::Err : super::std::fmt::Debug {
        let mut buf = String::new();
        let _ = io::stdin().read_line(&mut buf);
        buf.trim().parse::<T>().unwrap()
    }
    pub fn read_i32() -> i32 { read_item::<i32>() }

    pub fn read_list<T>() -> Vec<T>
        where T : super::std::str::FromStr,
              <T as super::std::str::FromStr>::Err : super::std::fmt::Debug,
              super::std::vec::Vec<T> : super::std::iter::FromIterator<T> {
        let mut buf = String::new();
        let _ = io::stdin().read_line(&mut buf);
        let mut res = Vec::new();
        for item in buf.trim().split_whitespace().map(|s| s.parse::<T>()).into_iter() {
            match item {
                Ok(i) => res.push(i),
                _ => (),
            }
        }
        res
    }
    pub fn read_list_i32() -> Vec<i32> { read_list::<i32>() }

    pub fn read_tuple2<T>() -> (T, T) 
        where T : super::std::str::FromStr,
              T : Copy,
              <T as super::std::str::FromStr>::Err : super::std::fmt::Debug,
              super::std::vec::Vec<T> : super::std::iter::FromIterator<T> {
        let ls = read_list::<T>();
        (ls[0], ls[1])
    }
    pub fn read_tuple3<T>() -> (T, T, T)
        where T : super::std::str::FromStr,
              T : Copy,
              <T as super::std::str::FromStr>::Err : super::std::fmt::Debug,
              super::std::vec::Vec<T> : super::std::iter::FromIterator<T> {
        let ls = read_list::<T>();
        (ls[0], ls[1], ls[2])
    }
} // mod procon

fn solve(m : i32) -> i32 {
    let km = m as f32 / 1000.0;
    let vv = match m {
        v if                v <     100 => 0.0,
        v if    100 <= v && v <=  5_000 => km * 10.0,
        v if  6_000 <= v && v <= 30_000 => km + 50.0,
        v if 35_000 <= v && v <= 70_000 => (km - 30.0) / 5.0 + 80.0,
        _                               => 89.0,
    };
    vv as i32
}

use procon::*;
fn main() {
    let m = read_i32();

    assert_eq!(solve(10), 0);
    assert_eq!(solve(100), 1);
    assert_eq!(solve(2000), 20);
    assert_eq!(solve(5000), 50);
    assert_eq!(solve(6000), 56);
    assert_eq!(solve(15000), 65);
    assert_eq!(solve(35000), 81);
    let vv = solve(m);
    println!("{:02}", vv);
}

Submission Info

Submission Time
Task B - 視程の通報
User tsuzuki
Language Rust (1.15.1)
Score 100
Code Size 2894 Byte
Status AC
Exec Time 2 ms
Memory 4352 KB

Compile Error

warning: unknown lint: `unused_macros`, #[warn(unknown_lints)] on by default
 --> ./Main.rs:2:9
  |
2 | #[allow(unused_macros)]
  |         ^^^^^^^^^^^^^

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 38
Set Name Test Cases
all 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 2 ms 4352 KB
00_sample_02.txt AC 2 ms 4352 KB
00_sample_03.txt AC 2 ms 4352 KB
test_01.txt AC 2 ms 4352 KB
test_02.txt AC 2 ms 4352 KB
test_03.txt AC 2 ms 4352 KB
test_04.txt AC 2 ms 4352 KB
test_05.txt AC 2 ms 4352 KB
test_06.txt AC 2 ms 4352 KB
test_07.txt AC 2 ms 4352 KB
test_08.txt AC 2 ms 4352 KB
test_09.txt AC 2 ms 4352 KB
test_10.txt AC 2 ms 4352 KB
test_11.txt AC 2 ms 4352 KB
test_12.txt AC 2 ms 4352 KB
test_13.txt AC 2 ms 4352 KB
test_14.txt AC 2 ms 4352 KB
test_15.txt AC 2 ms 4352 KB
test_16.txt AC 2 ms 4352 KB
test_17.txt AC 2 ms 4352 KB
test_18.txt AC 2 ms 4352 KB
test_19.txt AC 2 ms 4352 KB
test_20.txt AC 2 ms 4352 KB
test_21.txt AC 2 ms 4352 KB
test_22.txt AC 2 ms 4352 KB
test_23.txt AC 2 ms 4352 KB
test_24.txt AC 2 ms 4352 KB
test_25.txt AC 2 ms 4352 KB
test_26.txt AC 2 ms 4352 KB
test_27.txt AC 2 ms 4352 KB
test_28.txt AC 2 ms 4352 KB
test_29.txt AC 2 ms 4352 KB
test_30.txt AC 2 ms 4352 KB
test_31.txt AC 2 ms 4352 KB
test_32.txt AC 2 ms 4352 KB
test_33.txt AC 2 ms 4352 KB
test_34.txt AC 2 ms 4352 KB
test_35.txt AC 2 ms 4352 KB