結果

問題 No.2656 XOR Slimes
ユーザー miya145592miya145592
提出日時 2024-03-01 23:21:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 667 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 86,712 KB
最終ジャッジ日時 2024-03-01 23:21:42
合計ジャッジ時間 26,252 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 39 ms
53,460 KB
testcase_02 AC 43 ms
53,460 KB
testcase_03 AC 38 ms
53,460 KB
testcase_04 AC 45 ms
53,460 KB
testcase_05 AC 50 ms
53,460 KB
testcase_06 AC 45 ms
53,460 KB
testcase_07 AC 43 ms
53,460 KB
testcase_08 AC 372 ms
80,164 KB
testcase_09 AC 550 ms
81,876 KB
testcase_10 AC 367 ms
81,480 KB
testcase_11 AC 597 ms
82,548 KB
testcase_12 AC 566 ms
82,404 KB
testcase_13 AC 406 ms
82,052 KB
testcase_14 AC 373 ms
82,728 KB
testcase_15 AC 301 ms
80,996 KB
testcase_16 AC 611 ms
86,132 KB
testcase_17 AC 405 ms
84,852 KB
testcase_18 AC 398 ms
81,516 KB
testcase_19 AC 459 ms
85,644 KB
testcase_20 AC 404 ms
83,896 KB
testcase_21 AC 571 ms
81,892 KB
testcase_22 AC 499 ms
82,136 KB
testcase_23 AC 375 ms
83,508 KB
testcase_24 AC 420 ms
85,232 KB
testcase_25 AC 589 ms
84,052 KB
testcase_26 AC 565 ms
83,724 KB
testcase_27 AC 407 ms
85,172 KB
testcase_28 AC 538 ms
82,700 KB
testcase_29 AC 467 ms
85,592 KB
testcase_30 AC 559 ms
83,336 KB
testcase_31 AC 641 ms
84,732 KB
testcase_32 AC 376 ms
84,096 KB
testcase_33 AC 565 ms
83,624 KB
testcase_34 AC 511 ms
81,564 KB
testcase_35 AC 354 ms
82,608 KB
testcase_36 AC 309 ms
80,172 KB
testcase_37 AC 307 ms
80,508 KB
testcase_38 AC 598 ms
86,712 KB
testcase_39 AC 556 ms
83,956 KB
testcase_40 AC 592 ms
85,212 KB
testcase_41 AC 468 ms
85,404 KB
testcase_42 AC 503 ms
81,216 KB
testcase_43 AC 512 ms
82,076 KB
testcase_44 AC 575 ms
84,092 KB
testcase_45 AC 667 ms
85,924 KB
testcase_46 AC 347 ms
81,868 KB
testcase_47 AC 344 ms
82,380 KB
testcase_48 AC 543 ms
81,724 KB
testcase_49 AC 341 ms
82,636 KB
testcase_50 AC 522 ms
82,388 KB
testcase_51 AC 574 ms
84,748 KB
testcase_52 AC 308 ms
80,872 KB
testcase_53 AC 508 ms
81,040 KB
testcase_54 AC 280 ms
80,344 KB
testcase_55 AC 308 ms
80,512 KB
testcase_56 AC 307 ms
81,480 KB
testcase_57 AC 326 ms
80,876 KB
testcase_58 AC 438 ms
80,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
import sys
input = sys.stdin.readline
N = int(input())
X = list(map(int, input().split()))
A = list(map(int, input().split()))
S = [0]
for a in A:
    S.append(S[-1]^a)
INF = sum(A)
dp3 = [INF for _ in range(N)]
stack = [(0, 0)]
while stack:
    sco, i = heapq.heappop(stack)
    if i>=1 and dp3[i-1]<sco:
        continue
    for j in range(i, N):
        if sco+(S[j+1]^S[i])+(X[j]-X[i]) < dp3[j]:
            dp3[j] = sco+(S[j+1]^S[i])+(X[j]-X[i])
            heapq.heappush(stack, (dp3[j], j+1))
print(dp3[-1])
0