結果
問題 | No.1818 6 Operations |
ユーザー |
|
提出日時 | 2022-01-25 13:37:34 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 662 bytes |
コンパイル時間 | 476 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 365,824 KB |
最終ジャッジ日時 | 2024-12-16 02:30:21 |
合計ジャッジ時間 | 90,286 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 TLE * 25 |
ソースコード
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))