結果

問題 No.2673 A present from B
ユーザー 👑 timitimi
提出日時 2024-03-15 22:34:29
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 444 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 71,080 KB
最終ジャッジ日時 2024-03-15 22:34:38
合計ジャッジ時間 2,441 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 37 ms
53,460 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 38 ms
53,460 KB
testcase_10 AC 37 ms
53,460 KB
testcase_11 AC 38 ms
53,460 KB
testcase_12 RE -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 WA -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 WA -
testcase_22 AC 40 ms
53,460 KB
testcase_23 AC 38 ms
53,460 KB
testcase_24 AC 36 ms
53,460 KB
testcase_25 AC 37 ms
53,460 KB
testcase_26 AC 36 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int, input().split())
A=list(map(int, input().split()))
B=[i+1 for i in range(N)]
C=[]
C.append(B.copy())
for a in A:
  B[a-1],B[a]=B[a],B[a-1]
  C.append(B.copy()) 

B=[i+1 for i in range(N)]
D=[]
D.append(B.copy())
for a in A[::-1]:
  B[a-1],B[a]=B[a],B[a-1]
  D.append(B.copy()) 
D=D[::-1]

ans=[10**10]*N
for i in range(N):
  d=D[i].index(1)
  CC=C[i]
  for j in range(N):
    ans[CC[j]-1]=min(ans[CC[j]-1],abs(d-j))
print(*ans[1:])
0