Submission #3437802


Source Code Expand

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (n,t) = {
        let t = read_vec::<usize>();
        (t[0],t[1])
    };
    let tn = read_vec::<usize>();
    let mut ans = 0;
    for j in 0..n-1{
        if tn[j+1]-tn[j] < t {
            ans += tn[j+1]-tn[j]
        } else {
            ans += t;
        }
    }
    ans += t;
    println!("{}",ans);
}

Submission Info

Submission Time
Task C - Sentou
User elaina
Language Rust (1.15.1)
Score 300
Code Size 774 Byte
Status AC
Exec Time 19 ms
Memory 8444 KB

Compile Error

warning: function is never used: `read_vec2`, #[warn(dead_code)] on by default
  --> ./Main.rs:13:1
   |
13 |   fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
   |  _^ starting here...
14 | |     (0..n).map(|_| read_vec()).collect()
15 | | }
   | |_^ ...ending here

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 5
AC × 13
Set Name Test Cases
Sample example0, example1, example2, example3, example4
All example0, example1, example2, example3, example4, maxrand0, maxrand1, maxrand2, rand0, rand1, rand2, rand3, rand4
Case Name Status Exec Time Memory
example0 AC 2 ms 4352 KB
example1 AC 2 ms 4352 KB
example2 AC 2 ms 4352 KB
example3 AC 2 ms 4352 KB
example4 AC 2 ms 4352 KB
maxrand0 AC 19 ms 8444 KB
maxrand1 AC 19 ms 8444 KB
maxrand2 AC 19 ms 8444 KB
rand0 AC 2 ms 4352 KB
rand1 AC 2 ms 4352 KB
rand2 AC 2 ms 4352 KB
rand3 AC 2 ms 4352 KB
rand4 AC 2 ms 4352 KB