結果

問題 No.1884 Sequence
ユーザー titan23titan23
提出日時 2022-06-14 13:34:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 755 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 169,252 KB
最終ジャッジ日時 2024-04-10 06:55:25
合計ジャッジ時間 6,905 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,540 KB
testcase_01 AC 40 ms
55,608 KB
testcase_02 AC 40 ms
54,976 KB
testcase_03 AC 41 ms
55,720 KB
testcase_04 AC 40 ms
55,520 KB
testcase_05 AC 41 ms
55,300 KB
testcase_06 AC 41 ms
54,620 KB
testcase_07 AC 41 ms
53,996 KB
testcase_08 AC 41 ms
54,200 KB
testcase_09 AC 41 ms
55,184 KB
testcase_10 AC 221 ms
150,532 KB
testcase_11 AC 217 ms
150,876 KB
testcase_12 AC 70 ms
91,540 KB
testcase_13 AC 74 ms
95,476 KB
testcase_14 AC 78 ms
93,548 KB
testcase_15 AC 145 ms
114,540 KB
testcase_16 AC 179 ms
138,468 KB
testcase_17 AC 102 ms
107,012 KB
testcase_18 AC 125 ms
116,544 KB
testcase_19 AC 105 ms
105,448 KB
testcase_20 AC 129 ms
106,516 KB
testcase_21 AC 113 ms
106,612 KB
testcase_22 AC 142 ms
112,712 KB
testcase_23 AC 180 ms
138,568 KB
testcase_24 AC 180 ms
138,196 KB
testcase_25 AC 181 ms
137,908 KB
testcase_26 AC 184 ms
138,836 KB
testcase_27 AC 79 ms
99,536 KB
testcase_28 AC 80 ms
98,984 KB
testcase_29 AC 79 ms
99,232 KB
testcase_30 AC 78 ms
99,680 KB
testcase_31 AC 135 ms
103,784 KB
testcase_32 AC 216 ms
169,252 KB
testcase_33 AC 117 ms
106,664 KB
testcase_34 AC 117 ms
106,424 KB
testcase_35 AC 90 ms
101,844 KB
testcase_36 AC 122 ms
100,660 KB
testcase_37 AC 117 ms
106,412 KB
testcase_38 AC 119 ms
105,620 KB
testcase_39 AC 105 ms
106,580 KB
testcase_40 AC 103 ms
106,796 KB
testcase_41 AC 168 ms
127,688 KB
testcase_42 AC 171 ms
127,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 中央ぞろえ

import sys
from collections import Counter
from math import gcd
input = lambda: sys.stdin.readline().rstrip()
inf = float('inf')

###############

n = int(input())
A = list(map(int, input().split()))
A.sort()
zero_cnt = 0
for i in range(n):
  if A[i] == 0:
    zero_cnt += 1
  else:
    break
C = A[zero_cnt:]
m = len(C)
if m <= 1:
  print('Yes')
  exit()
st = set()
for i in range(m-1):
  st.add(C[i+1] - C[i])
delta = 0
for i in st:
  delta = gcd(delta, i)

if len(C) > len(set(C)):
  if len(Counter(C)) >= 2:
    print('No')
  else:
    print('Yes')
  exit()
need = 0
for i in range(m-1):
  if (C[i+1] - C[i]) % delta != 0:
    print('No')
    exit()
  need += (C[i+1] - C[i]) // delta - 1
print('Yes' if need <= zero_cnt else 'No')
0