結果

問題 No.2248 max(C)-min(C)
ユーザー ikomaikoma
提出日時 2023-03-18 01:20:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 798 ms / 3,000 ms
コード長 607 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 81,752 KB
実行使用メモリ 143,832 KB
最終ジャッジ日時 2023-10-18 16:48:39
合計ジャッジ時間 16,590 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,568 KB
testcase_01 AC 38 ms
53,568 KB
testcase_02 AC 38 ms
53,568 KB
testcase_03 AC 47 ms
61,960 KB
testcase_04 AC 44 ms
59,548 KB
testcase_05 AC 41 ms
53,568 KB
testcase_06 AC 58 ms
66,684 KB
testcase_07 AC 58 ms
68,744 KB
testcase_08 AC 61 ms
68,768 KB
testcase_09 AC 60 ms
68,744 KB
testcase_10 AC 41 ms
53,568 KB
testcase_11 AC 59 ms
68,740 KB
testcase_12 AC 47 ms
61,896 KB
testcase_13 AC 56 ms
66,672 KB
testcase_14 AC 58 ms
68,744 KB
testcase_15 AC 63 ms
68,784 KB
testcase_16 AC 47 ms
61,960 KB
testcase_17 AC 61 ms
68,772 KB
testcase_18 AC 186 ms
117,512 KB
testcase_19 AC 77 ms
79,800 KB
testcase_20 AC 212 ms
143,248 KB
testcase_21 AC 209 ms
143,060 KB
testcase_22 AC 163 ms
109,072 KB
testcase_23 AC 127 ms
96,008 KB
testcase_24 AC 85 ms
83,744 KB
testcase_25 AC 194 ms
117,220 KB
testcase_26 AC 190 ms
113,528 KB
testcase_27 AC 195 ms
117,324 KB
testcase_28 AC 74 ms
77,748 KB
testcase_29 AC 192 ms
117,692 KB
testcase_30 AC 118 ms
93,248 KB
testcase_31 AC 215 ms
143,832 KB
testcase_32 AC 91 ms
85,628 KB
testcase_33 AC 106 ms
90,992 KB
testcase_34 AC 231 ms
143,396 KB
testcase_35 AC 230 ms
143,292 KB
testcase_36 AC 215 ms
143,832 KB
testcase_37 AC 140 ms
102,896 KB
testcase_38 AC 672 ms
122,632 KB
testcase_39 AC 660 ms
122,624 KB
testcase_40 AC 662 ms
122,660 KB
testcase_41 AC 572 ms
116,844 KB
testcase_42 AC 647 ms
122,648 KB
testcase_43 AC 587 ms
116,516 KB
testcase_44 AC 694 ms
122,432 KB
testcase_45 AC 537 ms
112,212 KB
testcase_46 AC 342 ms
98,716 KB
testcase_47 AC 659 ms
122,644 KB
testcase_48 AC 554 ms
133,724 KB
testcase_49 AC 781 ms
143,028 KB
testcase_50 AC 775 ms
142,968 KB
testcase_51 AC 783 ms
143,024 KB
testcase_52 AC 798 ms
143,028 KB
testcase_53 AC 183 ms
84,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *
INF=1<<60
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
M=[]
mx=-INF
for i in range(N):
    if A[i]>B[i]:A[i],B[i]=B[i],A[i]
    M.append(A[i]+B[i]>>1)
heap=[]
for i,a in enumerate(A):
    heappush(heap, (a,i))
    mx = max(mx,a)
ans=mx-heap[0][0]
while True:
    x,i = heappop(heap)
    if x==B[i]:break
    if x==M[i]:
        b=B[i]
        heappush(heap, (b,i))
        mx = max(mx,b)
    else:
        m = M[i]
        heappush(heap, (m,i))
        mx = max(mx,m)
    ans = min(ans, mx-heap[0][0])

print(ans)
0