結果

問題 No.1884 Sequence
ユーザー Yuto Ohnuki
提出日時 2022-04-01 22:28:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 844 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 81,472 KB
実行使用メモリ 135,768 KB
最終ジャッジ日時 2024-11-20 10:07:37
合計ジャッジ時間 8,347 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import heapq, math, itertools
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
inputs = sys.stdin.readline
mod = 10**9+7
inf = float('inf')
#sys.setrecursionlimit(10**7)

def main():
  n = int(input())
  a = list(map(int, inputs().split()))
  cnt, x = 0, []
  for aa in a:
    if aa==0:
      cnt += 1
    else:
      x.append(aa)
  x = sorted(x)
  y = []
  for i in range(1, len(x)):
    if x[i]-x[i-1]!=0:
      y.append(x[i]-x[i-1])
  if not y:
    print("Yes")
  else:
    d = min(y)
    flg = True
    num = 0
    for i in range(1, len(x)):
      dif = x[i]-x[i-1]
      if dif%d!=0:
        flg = False
      else:
        num += max((dif//d)-1,0)
        if num>cnt:
          flg = False
    print('Yes' if flg else 'No')


if __name__ == '__main__':
  main()
0