結果

問題 No.2248 max(C)-min(C)
ユーザー ntudantuda
提出日時 2023-03-19 09:05:08
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 2,808 ms / 3,000 ms
コード長 672 bytes
コンパイル時間 419 ms
使用メモリ 246,724 KB
最終ジャッジ日時 2023-03-19 09:05:56
合計ジャッジ時間 42,362 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 68 ms
75,772 KB
testcase_01 AC 61 ms
75,828 KB
testcase_02 AC 66 ms
75,880 KB
testcase_03 AC 71 ms
80,984 KB
testcase_04 AC 70 ms
80,460 KB
testcase_05 AC 66 ms
75,680 KB
testcase_06 AC 79 ms
81,168 KB
testcase_07 AC 87 ms
82,920 KB
testcase_08 AC 89 ms
82,368 KB
testcase_09 AC 88 ms
82,408 KB
testcase_10 AC 69 ms
75,776 KB
testcase_11 AC 89 ms
82,372 KB
testcase_12 AC 76 ms
80,964 KB
testcase_13 AC 85 ms
81,184 KB
testcase_14 AC 96 ms
82,036 KB
testcase_15 AC 96 ms
82,804 KB
testcase_16 AC 79 ms
80,892 KB
testcase_17 AC 86 ms
80,892 KB
testcase_18 AC 481 ms
192,940 KB
testcase_19 AC 151 ms
97,748 KB
testcase_20 AC 580 ms
212,692 KB
testcase_21 AC 506 ms
211,172 KB
testcase_22 AC 382 ms
165,684 KB
testcase_23 AC 288 ms
131,908 KB
testcase_24 AC 194 ms
102,548 KB
testcase_25 AC 515 ms
203,144 KB
testcase_26 AC 476 ms
185,948 KB
testcase_27 AC 532 ms
202,248 KB
testcase_28 AC 146 ms
95,664 KB
testcase_29 AC 492 ms
196,616 KB
testcase_30 AC 254 ms
126,864 KB
testcase_31 AC 563 ms
214,216 KB
testcase_32 AC 189 ms
105,964 KB
testcase_33 AC 259 ms
123,956 KB
testcase_34 AC 617 ms
212,700 KB
testcase_35 AC 605 ms
214,004 KB
testcase_36 AC 598 ms
212,516 KB
testcase_37 AC 389 ms
142,336 KB
testcase_38 AC 1,943 ms
224,884 KB
testcase_39 AC 1,874 ms
224,480 KB
testcase_40 AC 1,898 ms
225,028 KB
testcase_41 AC 1,623 ms
200,920 KB
testcase_42 AC 1,815 ms
224,864 KB
testcase_43 AC 1,642 ms
199,636 KB
testcase_44 AC 1,823 ms
225,008 KB
testcase_45 AC 1,387 ms
180,456 KB
testcase_46 AC 748 ms
133,720 KB
testcase_47 AC 1,787 ms
225,060 KB
testcase_48 AC 1,543 ms
200,720 KB
testcase_49 AC 2,808 ms
246,288 KB
testcase_50 AC 2,628 ms
246,636 KB
testcase_51 AC 2,666 ms
246,176 KB
testcase_52 AC 2,800 ms
246,724 KB
testcase_53 AC 429 ms
104,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

D = set()
E = []
Q = []
cmax = 0
for i in range(N):
    a = A[i]
    b = B[i]
    if a > b:
        a, b = b, a
    c = (a + b) // 2
    d = (a, (a + b) // 2, b)
    E.append(d)
    D |= set(d)
    Q.append((a, i, 0))
    if cmax < a:
        cmax = a
D = sorted(list(D))
heapify(Q)

ans = 10 ** 9
for d in D:
    while d > Q[0][0]:
        _, i, j = heappop(Q)
        if j == 2:
            print(ans)
            exit()
        add = E[i][j + 1]
        if cmax < add:
            cmax = add
        heappush(Q, (add, i, j + 1))
    ans = min(ans, cmax - d)
0