結果

問題 No.1884 Sequence
ユーザー lloyz
提出日時 2022-03-25 21:34:17
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 647 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 82,856 KB
実行使用メモリ 131,444 KB
最終ジャッジ日時 2024-10-14 05:27:56
合計ジャッジ時間 6,280 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
from math import gcd

n = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
num = 0
while A[-1] == 0:
    num += 1
    A.pop()
if len(A) == 1:
    print("Yes")
    exit()

A.reverse()
D = []
for i in range(1, len(A)):
    D.append(A[i] - A[i - 1])
counter = Counter(D)
D = list(counter.keys())

if min(D) == 0:
    for dif in D:
        num -= dif * counter[dif]
else:
    dif_gcd = D[0]
    for i in range(1, len(D)):
        dif_gcd = gcd(dif_gcd, D[i])

    for dif in D:
        cnt = dif // dif_gcd - 1
        num -= cnt * counter[dif]
if num >= 0:
    print("Yes")
else:
    print("No")
0