結果

問題 No.1884 Sequence
ユーザー Kude
提出日時 2022-03-25 21:28:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 220 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 140,964 KB
最終ジャッジ日時 2024-10-14 05:18:13
合計ジャッジ時間 6,408 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
n = int(input())
a = []
k = 0
for x in map(int, input().split()):
    if x == 0:
        k += 1
    else:
        a.append(x)
a = sorted(a)
ls = len(set(a))
n = len(a)
if ls == 1:
    print('Yes')
    exit()
elif ls != n:
    print('No')
    exit()
g = 0
for x, y in zip(a, a[1:]):
    g = gcd(g, y - x)
r = sum((y - x) // g - 1 for x, y in zip(a, a[1:]))
print('Yes' if r <= k else 'No')
0