結果

問題 No.1884 Sequence
コンテスト
ユーザー kept1994
提出日時 2022-04-24 00:06:31
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 676 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 149 ms
コンパイル使用メモリ 85,300 KB
実行使用メモリ 129,236 KB
最終ジャッジ日時 2026-03-11 18:04:38
合計ジャッジ時間 4,553 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/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 0 in diff and g != 0:
        print("No")
        return
    if g == 0:
        print("Yes")
        return
    ans = 0
    for d in diff:
        ans += d // g - 1
    if ans <= zero:
        print("Yes")
    else:
        print("No")

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