結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 39 ms
53,460 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 40 ms
53,460 KB
testcase_10 AC 41 ms
53,460 KB
testcase_11 AC 40 ms
53,460 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 37 ms
53,460 KB
testcase_23 WA -
testcase_24 WA -
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()))
dp=[[1000]*N for _ in range(N)]
#dp[i][j]:iの荷物をjに持ってくるのに必要な最小回数
for i in range(N):
  dp[i][i]=0
now=10**10
for i in range(N):
  for j in range(1,N):
    dp[i][j]=min(dp[i][j],dp[i][j-1]+1)
  for j in range(N-2,-1,-1):
    dp[i][j]=min(dp[i][j],dp[i][j+1]+1)
    
for a in A:
  for i in range(N):
    dp[i][a-1],dp[i][a]=dp[i][a],dp[i][a-1]
  for j in range(1,N):
    dp[i][j]=min(dp[i][j],dp[i][j-1]+1)
  for j in range(N-2,-1,-1):
    dp[i][j]=min(dp[i][j],dp[i][j+1]+1)

ans=[]
for i in range(1,N):
  ans.append(dp[i][0])
print(*ans)
0