結果

問題 No.1818 6 Operations
ユーザー ShirotsumeShirotsume
提出日時 2022-01-25 13:37:34
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 662 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 284,688 KB
最終ジャッジ日時 2024-05-09 13:08:14
合計ジャッジ時間 5,066 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
60,672 KB
testcase_01 AC 139 ms
89,472 KB
testcase_02 AC 48 ms
56,832 KB
testcase_03 AC 43 ms
54,912 KB
testcase_04 AC 44 ms
56,320 KB
testcase_05 AC 43 ms
55,040 KB
testcase_06 AC 44 ms
55,168 KB
testcase_07 AC 43 ms
55,296 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
s = []
t = []
for i in range(n):
    for _ in range(a[i]):
        s.append(1)
    s.append(0)
for i in range(m):
    for _ in range(b[i]):
        t.append(1)
    t.append(0)
s = ''.join(map(str, s));t = ''.join(map(str, t))
from functools import lru_cache
import sys
sys.setrecursionlimit(3 * 10 ** 5)
@lru_cache(maxsize=4096)
def ld(s, t):
    if not s: return len(t)
    if not t: return len(s)
    if s[0] == t[0]: return ld(s[1:], t[1:])
    l1 = ld(s, t[1:])
    l2 = ld(s[1:], t)
    l3 = ld(s[1:], t[1:])
    return 1 + min(l1, l2, l3)
print(ld(s, t))
0