結果

問題 No.1818 6 Operations
ユーザー 👑 rin204rin204
提出日時 2022-01-23 02:08:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 580 ms / 2,500 ms
コード長 575 bytes
コンパイル時間 914 ms
コンパイル使用メモリ 86,744 KB
実行使用メモリ 182,064 KB
最終ジャッジ日時 2023-08-19 02:22:40
合計ジャッジ時間 13,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
70,968 KB
testcase_01 AC 68 ms
75,556 KB
testcase_02 AC 65 ms
71,096 KB
testcase_03 AC 62 ms
70,860 KB
testcase_04 AC 64 ms
71,032 KB
testcase_05 AC 64 ms
71,160 KB
testcase_06 AC 65 ms
71,340 KB
testcase_07 AC 66 ms
71,064 KB
testcase_08 AC 243 ms
111,136 KB
testcase_09 AC 367 ms
136,096 KB
testcase_10 AC 244 ms
111,208 KB
testcase_11 AC 238 ms
108,988 KB
testcase_12 AC 345 ms
128,728 KB
testcase_13 AC 222 ms
114,532 KB
testcase_14 AC 308 ms
125,804 KB
testcase_15 AC 338 ms
133,752 KB
testcase_16 AC 271 ms
124,040 KB
testcase_17 AC 420 ms
146,720 KB
testcase_18 AC 574 ms
174,992 KB
testcase_19 AC 490 ms
171,568 KB
testcase_20 AC 523 ms
176,816 KB
testcase_21 AC 525 ms
178,520 KB
testcase_22 AC 480 ms
159,288 KB
testcase_23 AC 552 ms
182,064 KB
testcase_24 AC 473 ms
159,124 KB
testcase_25 AC 538 ms
181,964 KB
testcase_26 AC 485 ms
169,248 KB
testcase_27 AC 531 ms
173,172 KB
testcase_28 AC 244 ms
111,572 KB
testcase_29 AC 230 ms
109,340 KB
testcase_30 AC 567 ms
175,132 KB
testcase_31 AC 515 ms
181,660 KB
testcase_32 AC 580 ms
181,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
S = []
for a in A:
    S += [0] + [1] * a
T = []
for b in B:
    T += [0] + [1] * b
ls = len(S)
lt = len(T)
dp = [[1 << 30] * (lt + 1) for _ in range(ls + 1)]
dp[0][0] = 0

for i in range(1, ls + 1):
    for j in range(1, lt + 1):
        dp[i][j] = min(dp[i - 1][j] + 1, dp[i][j - 1] + 1)
        if S[i - 1] == T[j - 1]:
            dp[i][j] = min(dp[i][j], dp[i - 1][j - 1])
        else:
            dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + 1)

print(dp[ls][lt])
0