結果
| 問題 | No.1884 Sequence | 
| コンテスト | |
| ユーザー | 👑  SPD_9X2 | 
| 提出日時 | 2022-03-25 21:33:41 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 181 ms / 2,000 ms | 
| コード長 | 753 bytes | 
| コンパイル時間 | 201 ms | 
| コンパイル使用メモリ | 82,080 KB | 
| 実行使用メモリ | 118,648 KB | 
| 最終ジャッジ日時 | 2024-10-14 05:27:02 | 
| 合計ジャッジ時間 | 6,184 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 40 | 
ソースコード
import sys
from sys import stdin
import math
N = int(input())
A = list(map(int,input().split()))
A.sort()
d = None
z = 0
B = []
for i in range(N-1):
    if A[i] != 0:
        diff = A[i+1] - A[i]
        if d == None:
            d = diff
        else:
            d = math.gcd(d,diff)
    else:
        z += 1
for i in range(N):
    if A[i] != 0:
        B.append(A[i])
if len(B) == 0:
    print ("Yes")
    sys.exit()
if d == 0:
    if max(B) == min(B):
        print ("Yes")
    else:
        print ("No")
    sys.exit()
ind = 0
for i in range(B[0],B[-1]+1,d):
    if B[ind] == i:
        ind += 1
    else:
        z -= 1
    if z < 0:
        print ("No")
        sys.exit()
if ind == len(B):
    print ("Yes")
else:
    print ("No")
            
            
            
        