結果

問題 No.1818 6 Operations
コンテスト
ユーザー Shirotsume
提出日時 2022-01-25 13:37:34
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 662 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 366 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 326,144 KB
最終ジャッジ日時 2026-05-26 08:29:43
合計ジャッジ時間 4,736 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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