結果

問題 No.2248 max(C)-min(C)
ユーザー flygonflygon
提出日時 2023-03-17 22:25:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 81,580 KB
実行使用メモリ 202,756 KB
最終ジャッジ日時 2023-10-18 15:22:10
合計ジャッジ時間 17,631 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,404 KB
testcase_01 AC 36 ms
53,404 KB
testcase_02 AC 37 ms
53,404 KB
testcase_03 AC 61 ms
70,400 KB
testcase_04 AC 59 ms
70,400 KB
testcase_05 AC 53 ms
65,948 KB
testcase_06 AC 81 ms
76,440 KB
testcase_07 AC 76 ms
76,704 KB
testcase_08 AC 80 ms
76,704 KB
testcase_09 AC 86 ms
76,704 KB
testcase_10 AC 52 ms
65,948 KB
testcase_11 AC 75 ms
76,704 KB
testcase_12 AC 66 ms
73,008 KB
testcase_13 AC 73 ms
76,440 KB
testcase_14 AC 81 ms
76,704 KB
testcase_15 AC 75 ms
76,704 KB
testcase_16 AC 61 ms
70,400 KB
testcase_17 AC 75 ms
76,704 KB
testcase_18 AC 402 ms
180,436 KB
testcase_19 AC 131 ms
88,924 KB
testcase_20 AC 467 ms
202,432 KB
testcase_21 AC 422 ms
188,416 KB
testcase_22 AC 332 ms
156,304 KB
testcase_23 AC 242 ms
123,576 KB
testcase_24 AC 156 ms
96,032 KB
testcase_25 AC 424 ms
180,172 KB
testcase_26 AC 374 ms
172,388 KB
testcase_27 AC 400 ms
180,460 KB
testcase_28 AC 133 ms
87,104 KB
testcase_29 AC 426 ms
179,052 KB
testcase_30 AC 212 ms
112,156 KB
testcase_31 AC 443 ms
202,548 KB
testcase_32 AC 159 ms
96,400 KB
testcase_33 AC 211 ms
111,312 KB
testcase_34 AC 439 ms
202,740 KB
testcase_35 AC 438 ms
202,500 KB
testcase_36 AC 437 ms
202,756 KB
testcase_37 AC 287 ms
142,396 KB
testcase_38 AC 511 ms
193,784 KB
testcase_39 AC 522 ms
193,168 KB
testcase_40 AC 500 ms
192,404 KB
testcase_41 WA -
testcase_42 AC 509 ms
200,332 KB
testcase_43 AC 467 ms
184,168 KB
testcase_44 AC 511 ms
194,500 KB
testcase_45 AC 417 ms
173,096 KB
testcase_46 AC 290 ms
123,448 KB
testcase_47 AC 504 ms
193,428 KB
testcase_48 AC 481 ms
195,772 KB
testcase_49 AC 435 ms
196,076 KB
testcase_50 AC 438 ms
196,076 KB
testcase_51 AC 442 ms
196,072 KB
testcase_52 AC 433 ms
196,024 KB
testcase_53 AC 135 ms
89,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [(a[i]+b[i])//2 for i in range(n)]

dp = [[[0,0] for i in range(3)] for i in range(n)]

dp[0][0] = [a[0],a[0]]
dp[0][1] = [b[0],b[0]]
dp[0][2] = [c[0],c[0]]

for i in range(1, n):
  ai, bi,ci = a[i],b[i], c[i]
  for jj,j in enumerate([ai,bi,ci]):
    tmp = [10**10, -1, -1 ]
    tmp = min(tmp, [max(dp[i-1][0][0],j) - min(dp[i-1][0][1],j), max(dp[i-1][0][0],j ),min(dp[i-1][0][1],j) ])
    tmp = min(tmp, [max(dp[i-1][1][0],j) - min(dp[i-1][1][1],j), max(dp[i-1][1][0],j ),min(dp[i-1][1][1],j) ])
    tmp = min(tmp, [max(dp[i-1][2][0],j) - min(dp[i-1][2][1],j), max(dp[i-1][2][0],j ),min(dp[i-1][2][1],j) ])
    dp[i][jj] = tmp[1:]

ans = float("inf")
for i in range(3):
  ans = min(dp[-1][i][0] - dp[-1][i][1], ans)

print(ans)

0