結果

問題 No.2248 max(C)-min(C)
ユーザー ikomaikoma
提出日時 2023-03-18 01:09:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,298 ms / 3,000 ms
コード長 682 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 81,788 KB
実行使用メモリ 172,612 KB
最終ジャッジ日時 2023-10-18 16:47:20
合計ジャッジ時間 58,560 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,636 KB
testcase_01 AC 39 ms
53,636 KB
testcase_02 AC 38 ms
53,636 KB
testcase_03 AC 47 ms
63,644 KB
testcase_04 AC 47 ms
61,596 KB
testcase_05 AC 41 ms
55,684 KB
testcase_06 AC 62 ms
72,800 KB
testcase_07 AC 72 ms
76,356 KB
testcase_08 AC 71 ms
76,352 KB
testcase_09 AC 71 ms
76,272 KB
testcase_10 AC 42 ms
55,684 KB
testcase_11 AC 65 ms
74,044 KB
testcase_12 AC 49 ms
63,644 KB
testcase_13 AC 59 ms
70,720 KB
testcase_14 AC 75 ms
76,288 KB
testcase_15 AC 68 ms
74,120 KB
testcase_16 AC 49 ms
63,644 KB
testcase_17 AC 65 ms
73,480 KB
testcase_18 AC 1,716 ms
164,088 KB
testcase_19 AC 242 ms
84,236 KB
testcase_20 AC 1,984 ms
165,404 KB
testcase_21 AC 1,854 ms
169,700 KB
testcase_22 AC 1,263 ms
131,040 KB
testcase_23 AC 816 ms
128,512 KB
testcase_24 AC 335 ms
90,112 KB
testcase_25 AC 1,794 ms
165,520 KB
testcase_26 AC 1,573 ms
154,500 KB
testcase_27 AC 1,726 ms
165,540 KB
testcase_28 AC 208 ms
81,864 KB
testcase_29 AC 1,616 ms
161,552 KB
testcase_30 AC 644 ms
109,064 KB
testcase_31 AC 1,940 ms
164,876 KB
testcase_32 AC 374 ms
92,628 KB
testcase_33 AC 589 ms
106,944 KB
testcase_34 AC 1,959 ms
165,404 KB
testcase_35 AC 1,942 ms
165,404 KB
testcase_36 AC 1,960 ms
164,880 KB
testcase_37 AC 1,009 ms
138,760 KB
testcase_38 AC 2,141 ms
170,860 KB
testcase_39 AC 2,143 ms
170,860 KB
testcase_40 AC 2,145 ms
170,856 KB
testcase_41 AC 1,816 ms
153,436 KB
testcase_42 AC 2,119 ms
170,856 KB
testcase_43 AC 1,881 ms
156,336 KB
testcase_44 AC 2,155 ms
170,856 KB
testcase_45 AC 1,655 ms
140,864 KB
testcase_46 AC 855 ms
117,984 KB
testcase_47 AC 2,124 ms
168,740 KB
testcase_48 AC 854 ms
166,408 KB
testcase_49 AC 2,271 ms
172,612 KB
testcase_50 AC 2,260 ms
172,608 KB
testcase_51 AC 2,298 ms
172,608 KB
testcase_52 AC 2,276 ms
172,596 KB
testcase_53 AC 381 ms
90,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import _heappop_max,_heapify_max,_siftdown_max
heappop_max = _heappop_max;heapify_max = _heapify_max
def heappush_max(heap:list,item): heap.append(item); _siftdown_max(heap, 0, len(heap)-1)
INF=1<<60
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=INF
X=[]
Y=[]
heap=[]
for i,(a,b) in enumerate(zip(A,B)):
    if a>b:a,b=b,a
    m=a+b>>1
    X.append([b,m])
    heap.append(a)
    Y.append((a,i))
    Y.append((b,i))
    Y.append((m,i))
Y.sort()
heapify_max(heap)

for x,i in Y:
    mx=heap[0]
    ans = min(ans, mx-x)
    if X[i]:
        heappush_max(heap, X[i].pop())
    else:break
print(ans)
0