結果

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

ソースコード

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)
  if not x:
    print('Yes')
  else:
    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==0:
          if d!=0:
            flg = False
        elif 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