Submission #1758429


Source Code Expand

use std::io::*;
use std::io;
use std::str::FromStr;


fn read(s: &mut StdinLock) -> u32 {
    s.by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .fold(0, |a, x| (x as u8 - b'0') as u32 + a * 10)
}


fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();

    let mut it = buf.split_whitespace().map(|n| u64::from_str(n).unwrap());
    let a = it.next().unwrap();

    let mut vec = Vec::new();

    let mut s = stdin.lock();
    let s = &mut s;
    //    let mut acc: u32 = 0;
    for _ in 0..a {
        let n = read(s);
        vec.push(n);
    }



    vec.sort();

    let vs = a as usize;

    println!("{}", vec[vs - 1] - vec[0]);
}

Submission Info

Submission Time
Task B - Traveling AtCoDeer Problem
User nak3
Language Rust (1.15.1)
Score 200
Code Size 844 Byte
Status AC
Exec Time 2 ms
Memory 4352 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 6
Set Name Test Cases
Sample s1.txt, s2.txt
All in1.txt, in2.txt, in3.txt, in4.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
in1.txt AC 2 ms 4352 KB
in2.txt AC 2 ms 4352 KB
in3.txt AC 2 ms 4352 KB
in4.txt AC 2 ms 4352 KB
s1.txt AC 2 ms 4352 KB
s2.txt AC 2 ms 4352 KB