結果

問題 No.1884 Sequence
ユーザー ntuda
提出日時 2025-02-01 12:21:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 252 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 763 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 133,744 KB
最終ジャッジ日時 2025-02-01 12:22:08
合計ジャッジ時間 8,288 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
N = int(input())
A = list(map(int,input().split()))
A.sort()
c0 = 0
pre = 0
D = []
A2 = []
for a in A:
    if a == 0:
        c0 += 1
    else:
        A2.append(a)
        if pre != 0:
            D.append(a - pre)
        pre = a
N2 = len(A2)
if N2 == 0 or len(D) <= 1:
    print("Yes")
    exit()

amin= min(A2)
amax = max(A2)
if amin == amax:
    print("Yes")
    exit()

dmin= min(D)
dmax = max(D)
if dmin == 0 and dmax > 0:
    print("No")
    exit()

n0 = N - c0
g = 0
D.sort(reverse= True)
for d in D:
    g = gcd(g,d)
x = (amax - amin) // g + 1
if N >= x:
    print("Yes")
else:
    print("No")

0