結果

問題 No.2248 max(C)-min(C)
ユーザー ntudantuda
提出日時 2023-03-19 09:05:08
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 672 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 237,956 KB
最終ジャッジ日時 2023-11-01 13:40:11
合計ジャッジ時間 48,614 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,652 KB
testcase_01 AC 38 ms
53,652 KB
testcase_02 AC 37 ms
53,652 KB
testcase_03 AC 47 ms
61,972 KB
testcase_04 AC 44 ms
61,708 KB
testcase_05 AC 40 ms
53,652 KB
testcase_06 AC 60 ms
68,788 KB
testcase_07 AC 68 ms
72,952 KB
testcase_08 AC 67 ms
70,880 KB
testcase_09 AC 60 ms
68,728 KB
testcase_10 AC 40 ms
53,652 KB
testcase_11 AC 65 ms
70,888 KB
testcase_12 AC 50 ms
64,020 KB
testcase_13 AC 59 ms
68,792 KB
testcase_14 AC 60 ms
68,728 KB
testcase_15 AC 66 ms
70,892 KB
testcase_16 AC 49 ms
61,972 KB
testcase_17 AC 61 ms
68,720 KB
testcase_18 AC 570 ms
185,332 KB
testcase_19 AC 136 ms
93,956 KB
testcase_20 AC 602 ms
208,372 KB
testcase_21 AC 587 ms
203,748 KB
testcase_22 AC 443 ms
153,248 KB
testcase_23 AC 314 ms
126,644 KB
testcase_24 AC 170 ms
96,524 KB
testcase_25 AC 576 ms
193,392 KB
testcase_26 AC 533 ms
177,600 KB
testcase_27 AC 559 ms
194,608 KB
testcase_28 AC 134 ms
89,592 KB
testcase_29 AC 541 ms
180,692 KB
testcase_30 AC 272 ms
114,060 KB
testcase_31 AC 606 ms
203,856 KB
testcase_32 AC 181 ms
98,276 KB
testcase_33 AC 245 ms
110,732 KB
testcase_34 AC 635 ms
209,740 KB
testcase_35 AC 624 ms
203,724 KB
testcase_36 AC 607 ms
208,864 KB
testcase_37 AC 357 ms
136,752 KB
testcase_38 AC 2,123 ms
211,920 KB
testcase_39 AC 2,173 ms
212,128 KB
testcase_40 AC 2,154 ms
210,592 KB
testcase_41 AC 1,845 ms
192,040 KB
testcase_42 AC 2,136 ms
210,620 KB
testcase_43 AC 1,919 ms
194,024 KB
testcase_44 AC 2,182 ms
211,728 KB
testcase_45 AC 1,723 ms
181,248 KB
testcase_46 AC 886 ms
121,472 KB
testcase_47 AC 2,169 ms
210,528 KB
testcase_48 AC 1,531 ms
186,680 KB
testcase_49 TLE -
testcase_50 TLE -
testcase_51 TLE -
testcase_52 TLE -
testcase_53 AC 441 ms
97,220 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