結果
| 問題 |
No.1884 Sequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-25 21:35:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 647 bytes |
| コンパイル時間 | 196 ms |
| コンパイル使用メモリ | 82,440 KB |
| 実行使用メモリ | 131,744 KB |
| 最終ジャッジ日時 | 2024-10-14 05:29:40 |
| 合計ジャッジ時間 | 6,290 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 RE * 2 |
ソースコード
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")