結果

問題 No.1818 6 Operations
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-01-22 18:38:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 472 ms / 2,500 ms
コード長 635 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 180,352 KB
最終ジャッジ日時 2023-08-18 13:04:35
合計ジャッジ時間 11,193 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,484 KB
testcase_01 AC 77 ms
76,280 KB
testcase_02 AC 72 ms
71,444 KB
testcase_03 AC 72 ms
71,680 KB
testcase_04 AC 75 ms
71,528 KB
testcase_05 AC 72 ms
71,456 KB
testcase_06 AC 71 ms
71,628 KB
testcase_07 AC 73 ms
71,532 KB
testcase_08 AC 212 ms
111,260 KB
testcase_09 AC 314 ms
134,328 KB
testcase_10 AC 179 ms
111,764 KB
testcase_11 AC 196 ms
108,900 KB
testcase_12 AC 269 ms
128,892 KB
testcase_13 AC 202 ms
113,292 KB
testcase_14 AC 249 ms
112,044 KB
testcase_15 AC 286 ms
134,284 KB
testcase_16 AC 240 ms
112,132 KB
testcase_17 AC 317 ms
135,020 KB
testcase_18 AC 451 ms
176,024 KB
testcase_19 AC 394 ms
156,816 KB
testcase_20 AC 437 ms
177,156 KB
testcase_21 AC 440 ms
178,736 KB
testcase_22 AC 357 ms
157,516 KB
testcase_23 AC 446 ms
179,812 KB
testcase_24 AC 360 ms
156,692 KB
testcase_25 AC 459 ms
179,716 KB
testcase_26 AC 370 ms
156,856 KB
testcase_27 AC 430 ms
173,556 KB
testcase_28 AC 244 ms
110,968 KB
testcase_29 AC 251 ms
109,612 KB
testcase_30 AC 468 ms
175,764 KB
testcase_31 AC 430 ms
179,984 KB
testcase_32 AC 472 ms
180,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
lA = []
lB = []
for a in A:
    lA.append(0)
    for i in range(a):
        lA.append(1)

for b in B:
    lB.append(0)
    for i in range(b):
        lB.append(1)


dp = [[0]*(len(lB)+1) for i in range(len(lA)+1)]
for i in range(len(lA)+1):
    dp[i][0] = i

for i in range(len(lB)+1):
    dp[0][i] = i

for i in range(1,len(lA)+1):
    for j in range(1,len(lB)+1):
        if lA[i-1] == lB[j-1]:
            dp[i][j] = dp[i-1][j-1]
        else:
            dp[i][j] = min(dp[i-1][j-1]+1,dp[i][j-1]+1,dp[i-1][j]+1)

print(dp[-1][-1])
0