結果

問題 No.2656 XOR Slimes
ユーザー shotoyooshotoyoo
提出日時 2024-03-01 22:09:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,191 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 84,188 KB
最終ジャッジ日時 2024-03-01 22:10:04
合計ジャッジ時間 4,221 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
62,948 KB
testcase_01 AC 42 ms
56,144 KB
testcase_02 AC 42 ms
56,144 KB
testcase_03 AC 42 ms
56,144 KB
testcase_04 WA -
testcase_05 AC 40 ms
56,144 KB
testcase_06 AC 39 ms
56,144 KB
testcase_07 AC 41 ms
56,144 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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
def dist(j,i):
    mid = (i-1+j)//2
    d = sum((abs(x[mid]-x[ind]) for ind in range(j,i)))
    # d = (x[mid]*(mid-j)) - (cumx[mid]-cumx[j]) + ((cumx[i]-cumx[mid]) - (x[mid]*(i-mid)))
    return d

for i in range(1,n+1):
    val = INF
    for j in range(i):
        d = dist(j,i)
        tmp = dp[j] + (cuma[i]^cuma[j]) + d
        val = min(val, tmp)
    dp[i] = val
print(dp[n])
0