Submission #1869225


Source Code Expand

#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

#[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

#[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where
        <T as FromStr>::Err: Debug,
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse().unwrap())
                .collect()
        }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let (n,c,k) = get!(usize, u64, u64);
    let mut ts = get!(u64; n);
    ts.sort();

    let mut b = ts[0] + k;
    let mut n = 0;
    let mut ans = 1;

    for &t in &ts {
        if b>=t && n < c {
            n +=1;
        } else {
            ans += 1;
            n = 1;
            b = t +k;
        }
    }

    println!("{}", ans);
}

Submission Info

Submission Time
Task A - Airport Bus
User hatoo
Language Rust (1.15.1)
Score 300
Code Size 2559 Byte
Status AC
Exec Time 20 ms
Memory 4352 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 12
Set Name Test Cases
Sample sample1.txt, sample2.txt
All sample1.txt, sample2.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, sample1.txt, sample2.txt
Case Name Status Exec Time Memory
in1.txt AC 2 ms 4352 KB
in2.txt AC 20 ms 4352 KB
in3.txt AC 20 ms 4352 KB
in4.txt AC 20 ms 4352 KB
in5.txt AC 2 ms 4352 KB
in6.txt AC 20 ms 4352 KB
in7.txt AC 18 ms 4352 KB
in8.txt AC 20 ms 4352 KB
sample1.txt AC 2 ms 4352 KB
sample2.txt AC 2 ms 4352 KB