結果
問題 |
No.406 鴨等間隔の法則
|
ユーザー |
|
提出日時 | 2021-11-18 23:47:10 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 788 bytes |
コンパイル時間 | 16,158 ms |
コンパイル使用メモリ | 382,756 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 23:43:21 |
合計ジャッジ時間 | 18,747 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
fn main() { let n: usize = get_a_value(); let mut xv: Vec<u64> = get_line(); xv.sort(); xv.dedup(); if xv.len() != n { println!("NO"); return; } let delta = xv[1] - xv[0]; for i in 2..n { if xv[i] - xv[i - 1] != delta { println!("NO"); return; } } println!("YES"); } #[allow(unused)] fn get_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 get_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() }