結果
問題 | No.2656 XOR Slimes |
ユーザー |
|
提出日時 | 2024-03-01 22:11:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 732 ms / 2,000 ms |
コード長 | 629 bytes |
コンパイル時間 | 276 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 273,232 KB |
最終ジャッジ日時 | 2024-09-29 14:09:33 |
合計ジャッジ時間 | 32,269 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 55 |
ソースコード
import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n = int(input()) x = list(map(int,input().split())) a = list(map(int,input().split())) sum = [[0]*n for i in range(n)] for l in range(n): now = 0 for r in range(l, n): now ^= a[r] sum[l][r] = now + x[r] - x[l] dp = [10**15]*(n+1) dp[0] = 0 for i in range(1, n+1): for j in range(1,i+1): tmp = sum[j-1][i-1] dp[i] = min(dp[i],tmp+dp[j-1]) print(dp[-1])