結果

問題 No.1884 Sequence
ユーザー kept1994
提出日時 2022-04-23 23:58:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 634 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 132,204 KB
最終ジャッジ日時 2024-06-25 08:56:18
合計ジャッジ時間 6,574 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
import math

def main():
    N = int(input())
    A = list(map(int, input().split()))
    aa = []
    zero = 0
    for i in A:
        if i != 0:
            aa.append(i)
        else:
            zero += 1
    aa.sort()
    diff = []
    g = 0
    for i in range(len(aa) - 1):
        diff.append(aa[i + 1] - aa[i])
        g = math.gcd(g, aa[i + 1] - aa[i])

    if g == 0:
        print("Yes")
        return
    
    ans = 0
    for d in diff:
        ans += d // g - 1
    # print(ans)
    if ans <= zero:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()
0