結果

問題 No.21 平均の差
ユーザー nomeaningnomeaning
提出日時 2019-04-17 21:40:23
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 363 bytes
コンパイル時間 5,597 ms
コンパイル使用メモリ 165,568 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 07:35:31
合計ジャッジ時間 4,586 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 0 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 0 ms
4,348 KB
testcase_08 AC 0 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `K`
 --> Main.rs:9:9
  |
9 |     let K = read_i32();
  |         ^ help: if this is intentional, prefix it with an underscore: `_K`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: variable `N` should have a snake case name
 --> Main.rs:8:9
  |
8 |     let N = read_i32();
  |         ^ help: convert the identifier to snake case: `n`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: variable `K` should have a snake case name
 --> Main.rs:9:9
  |
9 |     let K = read_i32();
  |         ^ help: convert the identifier to snake case (notice the capitalization): `k`

warning: 3 warnings emitted

ソースコード

diff #

fn read_i32() -> i32 {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().parse().unwrap()
}

fn main() {
    let N = read_i32();
    let K = read_i32();
    let mut n = vec![0; N as usize];
    for i in 0..N {
        n[i as usize] = read_i32();
    }
    n.sort();
    println!("{}", n[n.len() - 1] - n[0]);
}
0