結果
| 問題 | No.1884 Sequence |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-27 11:16:46 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,155 bytes |
| 記録 | |
| コンパイル時間 | 492 ms |
| コンパイル使用メモリ | 20,696 KB |
| 実行使用メモリ | 1,326,016 KB |
| 最終ジャッジ日時 | 2026-03-26 04:01:20 |
| 合計ジャッジ時間 | 49,521 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 1 |
| other | AC * 20 RE * 3 TLE * 7 MLE * 10 |
ソースコード
from itertools import pairwise
def gcd(*numbers: int) -> int:
if len(numbers) == 1:
return numbers[0]
if len(numbers) == 2:
a, b = numbers
if a < b:
a, b = b, a
while True:
if a % b == 0:
return b
a, b = b, a % b
first_gcd = gcd(*numbers[:2])
return gcd(first_gcd, *numbers[2:])
def is_positive(num: int) -> bool:
return num > 0
def main():
N = int(input())
A = list(map(int, input().split()))
A_fixed = list(filter(is_positive, A))
if len(A_fixed) in (0, 1):
print("Yes")
return
A_fixed.sort()
A_diff = [a_elm2 - a_elm1 for a_elm1, a_elm2 in pairwise(A_fixed)]
if (diff_zero_num := A_diff.count(0)):
if diff_zero_num == len(A_diff):
print("Yes")
else:
print("No")
return
A_diff_gcd = gcd(*A_diff)
A_diff_interpolated_num = list(map(
lambda num: num // A_diff_gcd - 1, A_diff))
if sum(A_diff_interpolated_num) <= len(A) - len(A_fixed):
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()