結果

問題 No.2656 XOR Slimes
ユーザー LyricalMaestro
提出日時 2025-10-04 03:07:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 76,540 KB
最終ジャッジ日時 2025-10-04 03:08:10
合計ジャッジ時間 11,190 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 55
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/2656

MAX_VALUE = 10 ** 18

def main():
    N = int(input())
    X = list(map(int, input().split()))
    A = list(map(int, input().split()))

    dp = [MAX_VALUE] * (N + 1)
    dp[0] = 0
    for i in range(N):
        a = 0
        for j in reversed(range(i + 1)):
            a ^= A[j]

            cost =  X[i] - X[j]
            dp[i + 1] = min(dp[i + 1], dp[j] + a + cost)
    print(dp[-1])






if __name__ == "__main__":
    main()
0