結果

問題 No.2248 max(C)-min(C)
ユーザー Alex WiceAlex Wice
提出日時 2023-03-17 22:58:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,489 ms / 3,000 ms
コード長 578 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 81,504 KB
実行使用メモリ 145,900 KB
最終ジャッジ日時 2023-10-18 16:00:33
合計ジャッジ時間 35,122 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,428 KB
testcase_01 AC 39 ms
53,428 KB
testcase_02 AC 38 ms
53,428 KB
testcase_03 AC 47 ms
61,692 KB
testcase_04 AC 44 ms
59,376 KB
testcase_05 AC 40 ms
53,428 KB
testcase_06 AC 67 ms
66,516 KB
testcase_07 AC 61 ms
68,628 KB
testcase_08 AC 61 ms
68,620 KB
testcase_09 AC 56 ms
66,448 KB
testcase_10 AC 40 ms
53,428 KB
testcase_11 AC 59 ms
66,544 KB
testcase_12 AC 48 ms
61,700 KB
testcase_13 AC 56 ms
64,460 KB
testcase_14 AC 58 ms
66,468 KB
testcase_15 AC 62 ms
68,604 KB
testcase_16 AC 48 ms
61,704 KB
testcase_17 AC 57 ms
66,456 KB
testcase_18 AC 255 ms
120,080 KB
testcase_19 AC 105 ms
82,424 KB
testcase_20 AC 274 ms
137,572 KB
testcase_21 AC 264 ms
119,812 KB
testcase_22 AC 217 ms
120,748 KB
testcase_23 AC 174 ms
99,508 KB
testcase_24 AC 120 ms
87,816 KB
testcase_25 AC 260 ms
116,992 KB
testcase_26 AC 253 ms
121,324 KB
testcase_27 AC 253 ms
117,508 KB
testcase_28 AC 104 ms
79,988 KB
testcase_29 AC 255 ms
122,232 KB
testcase_30 AC 155 ms
94,720 KB
testcase_31 AC 277 ms
136,556 KB
testcase_32 AC 119 ms
89,012 KB
testcase_33 AC 144 ms
92,416 KB
testcase_34 AC 300 ms
137,624 KB
testcase_35 AC 289 ms
137,596 KB
testcase_36 AC 276 ms
136,680 KB
testcase_37 AC 190 ms
111,344 KB
testcase_38 AC 1,722 ms
127,400 KB
testcase_39 AC 1,693 ms
127,276 KB
testcase_40 AC 1,709 ms
127,268 KB
testcase_41 AC 1,455 ms
127,968 KB
testcase_42 AC 1,707 ms
127,496 KB
testcase_43 AC 1,527 ms
127,144 KB
testcase_44 AC 1,741 ms
127,064 KB
testcase_45 AC 1,328 ms
129,608 KB
testcase_46 AC 690 ms
100,136 KB
testcase_47 AC 1,682 ms
127,284 KB
testcase_48 AC 1,445 ms
140,172 KB
testcase_49 AC 2,443 ms
145,900 KB
testcase_50 AC 2,447 ms
145,816 KB
testcase_51 AC 2,489 ms
145,720 KB
testcase_52 AC 2,472 ms
145,740 KB
testcase_53 AC 374 ms
87,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

pq = []
for i in range(N):
    if A[i] > B[i]: A[i],B[i]=B[i],A[i]
    pq.append([A[i], i, 0])

from heapq import *
hi = max(x for x,i,j in pq)
heapify(pq)
ans = hi - pq[0][0]
while pq:
    x,i,j = heappop(pq)
    if j == 2:
        break
    if j == 0:
        x = A[i] + B[i] >> 1
        hi = max(hi, x)
        heappush(pq, [x,i,j+1])
    if j == 1:
        x = B[i]
        hi = max(hi, x)
        heappush(pq, [x,i,j+1])
    if pq:
        ans = min(ans, hi - pq[0][0])

print(ans)
0