結果
問題 |
No.716 距離
|
ユーザー |
|
提出日時 | 2021-11-23 21:57:00 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,247 bytes |
コンパイル時間 | 24,846 ms |
コンパイル使用メモリ | 377,800 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 19:36:33 |
合計ジャッジ時間 | 15,346 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 40 |
ソースコード
fn main() { let n: usize = input_a_value(); let mut a: Vec<i32> = input_line(); a.sort(); let max = (a[0] - a[n - 1]).abs(); let mut min = 2 * 100_000; for i in 1..n { min = std::cmp::min((a[i] - a[i - 1]).abs(), min); } println!("{}\n{}", min, max); } #[allow(unused)] fn input_a_value<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } #[allow(unused)] fn input_line<T: std::str::FromStr>() -> Vec<T> { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } #[allow(unused)] fn input_matrix_num<T: std::str::FromStr>(n_lines: usize) -> Vec<Vec<T>> { (0..n_lines).map(|_| input_line()).collect() } #[allow(unused)] fn input_line_string() -> String { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().to_string() } #[allow(unused)] fn input_line_vch() -> Vec<char> { input_line_string().chars().collect() } #[allow(unused)] fn input_matrix_ch(n_lines: usize) -> Vec<Vec<char>> { (0..n_lines).map(|_| input_line_vch()).collect() }