結果
問題 |
No.1884 Sequence
|
ユーザー |
![]() |
提出日時 | 2025-06-12 16:01:37 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 877 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 143,524 KB |
最終ジャッジ日時 | 2025-06-12 16:02:01 |
合計ジャッジ時間 | 5,519 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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()