結果
| 問題 | 
                            No.406 鴨等間隔の法則
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-02-21 02:08:43 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 14 ms / 2,000 ms | 
| コード長 | 599 bytes | 
| コンパイル時間 | 12,411 ms | 
| コンパイル使用メモリ | 385,304 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-07 11:58:52 | 
| 合計ジャッジ時間 | 13,915 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 29 | 
ソースコード
use std::io::stdin;
fn get_line() -> String {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().to_string()
}
fn main() {
    stdin().read_line(&mut String::new()).ok();
    let mut xs: Vec<i64> = get_line().split(' ').map(|x| x.parse().unwrap()).collect();
    xs.sort();
    let d = xs[1] - xs[0];
    let mut f = d != 0;
    for i in 1..(xs.len() - 1) {
        f = f && d == xs[i + 1] - xs[i];
        if !f {
            break;
        }
    }
    println!("{}",
        if f {
            "YES"
        }
        else {
            "NO"
        }
    );
}