結果
問題 |
No.2656 XOR Slimes
|
ユーザー |
|
提出日時 | 2024-03-02 00:26:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,586 ms / 2,000 ms |
コード長 | 589 bytes |
コンパイル時間 | 393 ms |
コンパイル使用メモリ | 82,088 KB |
実行使用メモリ | 116,656 KB |
最終ジャッジ日時 | 2024-09-29 15:42:39 |
合計ジャッジ時間 | 59,304 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 55 |
ソースコード
N = int(input()) X = list(map(int,input().split())) A = list(map(int,input().split())) from collections import defaultdict inf = 10 ** 13 d = defaultdict(lambda : inf) d[A[0]] = A[0] for i in range(N - 1): x = X[i] xx = X[i + 1] a = A[i + 1] nx = defaultdict(lambda : inf) b = A[i] for aa,u in d.items(): nx[aa ^ a] = min(nx[aa ^ a],u - aa + (aa ^ a) + xx - x) #print(u,aa,aa^a,xx,x,nx) if u + a < nx[a]: nx[a] = u + a d = nx #print(d) ans = inf for k in d.values(): if k < ans:ans = k print(ans)