結果

問題 No.406 鴨等間隔の法則
ユーザー lam6er
提出日時 2025-03-20 20:18:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 82,644 KB
実行使用メモリ 101,068 KB
最終ジャッジ日時 2025-03-20 20:19:22
合計ジャッジ時間 3,268 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
x = list(map(int, input().split()))

# Check for duplicates
if len(set(x)) != n:
    print("NO")
else:
    x_sorted = sorted(x)
    min_val = x_sorted[0]
    max_val = x_sorted[-1]
    total_diff = max_val - min_val

    # Check if total difference can be evenly divided by (n-1)
    if total_diff % (n - 1) != 0:
        print("NO")
    else:
        d = total_diff // (n - 1)
        # Check each consecutive pair
        valid = True
        for i in range(1, n):
            if x_sorted[i] - x_sorted[i-1] != d:
                valid = False
                break
        print("YES" if valid else "NO")
0