結果
| 問題 |
No.1884 Sequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-07 09:13:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 202 ms / 2,000 ms |
| コード長 | 732 bytes |
| コンパイル時間 | 419 ms |
| コンパイル使用メモリ | 82,168 KB |
| 実行使用メモリ | 134,000 KB |
| 最終ジャッジ日時 | 2025-01-07 09:14:02 |
| 合計ジャッジ時間 | 7,263 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
N = int(input())
A = list(map(int,input().split()))
A0 = []
A1 = []
for i in range(N):
if A[i]>0:
A1.append(A[i])
else:
A0.append(A[i])
A1 = sorted(A1)
if len(A1)<=2:
print("Yes")
else:
D = []
for i in range(len(A1)-1):
D.append(A1[i+1]-A1[i])
def gcd(a,b):
if b==0:
return a
return gcd(b,a%b)
if 0 in D:
if D.count(0)==len(D):
print("Yes")
else:
print("No")
else:
d = D[0]
for i in range(1,len(D)):
d = gcd(d,D[i])
cnt = 0
for i in range(len(D)):
cnt += D[i]//d-1
if cnt<=len(A0):
print("Yes")
else:
print("No")