結果

問題 No.21 平均の差
ユーザー ixTL255ixTL255
提出日時 2022-12-23 00:22:21
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 319 bytes
コンパイル時間 11,505 ms
コンパイル使用メモリ 401,856 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 04:05:06
合計ジャッジ時間 12,420 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `K`
  --> src/main.rs:11:6
   |
11 |     let K = read();
   |         ^ 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
  --> src/main.rs:10:6
   |
10 |     let N = read();
   |         ^ 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
  --> src/main.rs:11:6
   |
11 |     let K = read();
   |         ^ help: convert the identifier to snake case (notice the capitalization): `k`

ソースコード

diff #

use std::io;

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

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