結果

問題 No.406 鴨等間隔の法則
コンテスト
ユーザー cra77756176
提出日時 2022-12-07 23:10:13
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 7 ms / 2,000 ms
+ 33µs
コード長 514 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,255 ms
コンパイル使用メモリ 195,320 KB
実行使用メモリ 9,988 KB
最終ジャッジ日時 2026-09-16 04:02:49
合計ジャッジ時間 4,350 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::collections::HashSet;

fn main() {
    let mut xx = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok();
    let mut xx: Vec<u64> = xx
        .split_whitespace()
        .skip(1)
        .map(|n| n.parse().unwrap())
        .collect();

    xx.sort_unstable();

    let distances: HashSet<u64> = xx.windows(2).map(|x| x[1] - x[0]).collect();

    if distances.len() == 1 && !distances.contains(&0) {
        println!("YES");
    } else {
        println!("NO");
    }
}
0