結果

問題 No.1884 Sequence
ユーザー SidewaysOwl
提出日時 2022-03-25 22:45:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 834 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 178,444 KB
最終ジャッジ日時 2024-10-14 06:43:53
合計ジャッジ時間 6,509 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
a.sort()
cnt = 0
idx = -1
sa = [0]
same = set()
flg = False
for i in range(n):
    if idx ==-1 and a[i] != 0:
        idx = i
        same.add(a[i])
    elif idx != -1:
        if a[i] in same:
            flg = True
        sa.append(a[i]-a[idx])
        same.add(a[i])
    else:
        cnt += 1
if flg:
    if cnt != 0:
        if len(set(a)) <= 2:
            print("Yes")
        else:
            print("No")
    else:
        if len(set(a))== 1:
            print("Yes")
        else:
            print("No")
else:
    import math
    gcd_ = 0
    for i in range(1,len(sa)):
        gcd_ = math.gcd(gcd_,sa[i]-sa[i-1])
    baf = 0 
    for i in range(1,len(sa)):
        baf += (sa[i] - sa[i-1])//gcd_ - 1
    if baf <= cnt:
        print("Yes")
    else:
        print("No")
0