結果
問題 | No.135 とりあえず1次元の問題 |
ユーザー |
|
提出日時 | 2020-04-04 11:22:07 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 13 ms / 5,000 ms |
コード長 | 567 bytes |
コンパイル時間 | 11,449 ms |
コンパイル使用メモリ | 402,316 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-03 07:06:02 |
合計ジャッジ時間 | 13,064 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let mut a: Vec<usize> = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); a.sort(); a.dedup(); if a.len() < 2 { println!("0"); return; } let mut ans = 1 << 30; for i in 0..a.len() - 1 { ans = std::cmp::min(ans, a[i + 1] - a[i]); } println!("{}", ans); }