結果
| 問題 |
No.2656 XOR Slimes
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-03-01 21:45:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,122 bytes |
| コンパイル時間 | 189 ms |
| コンパイル使用メモリ | 82,580 KB |
| 実行使用メモリ | 72,676 KB |
| 最終ジャッジ日時 | 2024-09-29 13:42:46 |
| 合計ジャッジ時間 | 12,270 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 3 WA * 52 |
ソースコード
import sys, random
input = lambda : sys.stdin.readline().rstrip()
write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x))
debug = lambda x: sys.stderr.write(x+"\n")
YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18
LI = lambda v=0: list(map(lambda i: int(i)-v, input().split())); II=lambda : int(input()); SI=lambda : [ord(c)-ord("a") for c in input()]
def debug(_l_):
for s in _l_.split():
print(f"{s}={eval(s)}", end=" ")
print()
def dlist(*l, fill=0):
if len(l)==1:
return [fill]*l[0]
ll = l[1:]
return [dlist(*ll, fill=fill) for _ in range(l[0])]
n = int(input())
x = LI()
a = LI()
cuma = [0]
for v in a:
cuma.append(cuma[-1]^v)
cumx = [0]
for v in x:
cumx.append(cumx[-1]+v)
dp = [INF]*(n+1)
dp[0] = 0
for i in range(1,n+1):
aa = a[i-1]
xx = x[i-1]
val = INF
for j in range(i):
mid = (i-1+j)//2
d = (x[mid]*(mid-j)) - (cumx[mid]-cumx[j]) + ((cumx[i]-cumx[mid]) - (x[mid]*(i-mid)))
tmp = dp[j] + (cuma[i]^cuma[j]) + d
val = min(val, tmp)
dp[i] = val
print(dp[n])