結果
問題 | No.1884 Sequence |
ユーザー |
![]() |
提出日時 | 2022-03-25 21:44:38 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 460 ms / 2,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 145 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 34,436 KB |
最終ジャッジ日時 | 2024-10-14 05:40:52 |
合計ジャッジ時間 | 9,779 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
from math import gcd from functools import reduce n = int(input()) a = [*map(int, input().split())] a.sort() zeros = a.count(0) s = [*filter(lambda x: x > 0, a)] if len(s) <= 1: print("Yes") exit() sabun = [y - x for x, y in zip(s, s[1:])] g = reduce(gcd, sabun) if g == 0 or 0 in sabun: if all(x == 0 for x in sabun): print("Yes") else: print("No") exit() for x, y in zip(s, s[1:]): zeros -= (y - x) // g - 1 if zeros >= 0: print("Yes") else: print("No")