結果
問題 |
No.1884 Sequence
|
ユーザー |
![]() |
提出日時 | 2025-06-12 20:49:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 877 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 143,228 KB |
最終ジャッジ日時 | 2025-06-12 20:52:04 |
合計ジャッジ時間 | 6,907 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 WA * 5 |
ソースコード
import sys import math def main(): input = sys.stdin.read().split() N = int(input[0]) A = list(map(int, input[1:N+1])) S = [x for x in A if x != 0] M = len(S) if M == 0: print("Yes") return if M == 1: print("Yes") return S.sort() diffs = [] for i in range(1, M): diffs.append(S[i] - S[i-1]) g = 0 for d in diffs: g = math.gcd(g, d) if g == 0: print("Yes") return k = (S[-1] - S[0]) // g min_val = float('inf') for s in S: delta = (s - S[0]) // g current = (N - 1) - delta if current < 0: print("No") return if current < min_val: min_val = current term = (N - 1) - k max_x = min(term, min_val) print("Yes" if max_x >= 0 else "No") if __name__ == "__main__": main()