結果

問題 No.1884 Sequence
ユーザー lloyzlloyz
提出日時 2022-03-25 21:36:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 131,700 KB
最終ジャッジ日時 2024-04-22 06:15:24
合計ジャッジ時間 6,482 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,948 KB
testcase_01 AC 43 ms
54,628 KB
testcase_02 AC 42 ms
54,700 KB
testcase_03 AC 42 ms
54,732 KB
testcase_04 AC 41 ms
55,356 KB
testcase_05 AC 42 ms
54,456 KB
testcase_06 AC 42 ms
54,224 KB
testcase_07 AC 41 ms
54,412 KB
testcase_08 AC 42 ms
54,604 KB
testcase_09 AC 42 ms
54,748 KB
testcase_10 AC 221 ms
131,440 KB
testcase_11 AC 218 ms
131,700 KB
testcase_12 AC 74 ms
93,172 KB
testcase_13 AC 77 ms
96,544 KB
testcase_14 AC 80 ms
94,452 KB
testcase_15 AC 138 ms
106,464 KB
testcase_16 AC 160 ms
119,320 KB
testcase_17 AC 98 ms
107,288 KB
testcase_18 AC 115 ms
106,924 KB
testcase_19 AC 98 ms
105,692 KB
testcase_20 AC 120 ms
106,932 KB
testcase_21 AC 111 ms
107,284 KB
testcase_22 AC 130 ms
105,416 KB
testcase_23 AC 156 ms
119,400 KB
testcase_24 AC 158 ms
119,300 KB
testcase_25 AC 160 ms
118,256 KB
testcase_26 AC 159 ms
119,592 KB
testcase_27 AC 81 ms
101,264 KB
testcase_28 AC 83 ms
101,272 KB
testcase_29 AC 81 ms
101,448 KB
testcase_30 AC 83 ms
101,740 KB
testcase_31 AC 116 ms
101,560 KB
testcase_32 AC 160 ms
119,092 KB
testcase_33 AC 124 ms
118,380 KB
testcase_34 AC 122 ms
118,508 KB
testcase_35 AC 92 ms
104,468 KB
testcase_36 AC 127 ms
107,596 KB
testcase_37 AC 126 ms
118,384 KB
testcase_38 AC 124 ms
116,332 KB
testcase_39 AC 105 ms
107,020 KB
testcase_40 AC 107 ms
107,716 KB
testcase_41 AC 152 ms
114,368 KB
testcase_42 AC 152 ms
113,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
from math import gcd

n = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
num = 0
while A and A[-1] == 0:
    num += 1
    A.pop()
if len(A) <= 1:
    print("Yes")
    exit()

A.reverse()
D = []
for i in range(1, len(A)):
    D.append(A[i] - A[i - 1])
counter = Counter(D)
D = list(counter.keys())

if min(D) == 0:
    for dif in D:
        num -= dif * counter[dif]
else:
    dif_gcd = D[0]
    for i in range(1, len(D)):
        dif_gcd = gcd(dif_gcd, D[i])

    for dif in D:
        cnt = dif // dif_gcd - 1
        num -= cnt * counter[dif]
if num >= 0:
    print("Yes")
else:
    print("No")
0