結果

問題 No.1884 Sequence
ユーザー 👑 KazunKazun
提出日時 2022-03-25 21:32:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 507 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 149,284 KB
最終ジャッジ日時 2024-10-14 05:24:03
合計ジャッジ時間 6,421 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(A):
    from math import gcd

    E=[a for a in A if a!=0]
    M=A.count(0)

    if len(E)<=2:
        return True
    E.sort()
    g=0
    for i in range(len(E)-1):
        g=gcd(g,E[i+1]-E[i])

    E_min=E[0]
    E_max=E[-1]
    E_set=set(E)

    if len(E)!=len(E_set):
        return len(E_set)==1

    X=E_min
    for _ in range(M):
        while X in E_set:
            X+=g
        X+=g
    return X>=E_max

N=int(input())
A=list(map(int,input().split()))
print("Yes" if solve(A) else "No")
0