Submission #15478877


Source Code Expand

Copy
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input! {
        n: usize,
        k: Usize1,
        mut h: [i64; n],
    };
    h.sort();
    let mut ans = 1_000_000_000_i64;
    for i in k..n {
        let h_max = h[i];
        let h_min = h[i - k];
        ans = std::cmp::min(ans, h_max - h_min);
    }
    println!("{}", ans);
}

Submission Info

Submission Time
Task C - Christmas Eve
User bouzuya
Language Rust (1.42.0)
Score 300
Code Size 355 Byte
Status
Exec Time 32 ms
Memory 4216 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02
All 300 / 300 a01, a02, b03, b04, b05, b06, b07, b08, b09, b10
Case Name Status Exec Time Memory
a01 7 ms 2008 KB
a02 2 ms 2028 KB
b03 1 ms 2092 KB
b04 8 ms 3936 KB
b05 26 ms 4144 KB
b06 26 ms 4164 KB
b07 32 ms 4216 KB
b08 21 ms 4072 KB
b09 25 ms 4148 KB
b10 24 ms 4040 KB