結果
問題 | No.1884 Sequence |
ユーザー |
![]() |
提出日時 | 2022-05-12 14:19:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 191 ms / 2,000 ms |
コード長 | 712 bytes |
コンパイル時間 | 187 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 119,056 KB |
最終ジャッジ日時 | 2024-07-20 07:37:18 |
合計ジャッジ時間 | 6,743 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
import mathN = int(input())A = list(map(int, input().split()))A.sort()cnt = 0start = 0sa = []bad = set()bad_cnt = 0for i in range(N):if A[i] == 0:cnt += 1else:if start != 0:if A[i]-start > 0:sa.append(A[i]-start)else:bad.add(A[i])bad_cnt += 1start = A[i]if len(sa)==1:gcd = sa[0]elif len(sa)>1:gcd = math.gcd(gcd, sa[-1])res = 0if len(bad) > 1 or (len(bad)==1 and 1+bad_cnt+cnt<N):print('No')exit()if len(sa) == 0:print('Yes')exit()for i in range(len(sa)):res += (sa[i]//gcd-1)if cnt >= res:print('Yes')else:print('No')