結果

問題 No.2821 A[i] ← 2A[j] - A[i]
ユーザー むつある
提出日時 2024-07-26 22:46:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 464 ms / 1,500 ms
コード長 472 bytes
コンパイル時間 435 ms
コンパイル使用メモリ 82,264 KB
実行使用メモリ 135,756 KB
最終ジャッジ日時 2024-07-26 22:46:08
合計ジャッジ時間 7,260 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10 ** 7)
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')

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

def f(x):
  x=set(x)
  x=list(x)
  if len(x)<=2:
    return x
  x.sort()
  a=x[1]-x[0]
  b=x[2]-x[1]
  if a==b:
    return x[:2]
  if a<b:
    c=b%a
    return f([x[2]-a-c,x[2]-c,x[2]])
  else:
    c=a%b
    return f([x[1],x[1]+c,x[1]+c+b])
    
now=[]
for i in a:
  now.append(i)
  now=f(now)
  print(max(now)-min(now))
0