結果

問題 No.2248 max(C)-min(C)
ユーザー 👑 H20H20
提出日時 2023-03-24 11:11:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,463 ms / 3,000 ms
コード長 651 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 152,288 KB
最終ジャッジ日時 2023-12-16 08:27:43
合計ジャッジ時間 68,069 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 38 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 73 ms
72,908 KB
testcase_04 AC 71 ms
71,348 KB
testcase_05 AC 55 ms
64,032 KB
testcase_06 AC 110 ms
76,972 KB
testcase_07 AC 118 ms
77,316 KB
testcase_08 AC 117 ms
77,288 KB
testcase_09 AC 115 ms
77,188 KB
testcase_10 AC 53 ms
63,904 KB
testcase_11 AC 115 ms
77,176 KB
testcase_12 AC 83 ms
74,956 KB
testcase_13 AC 110 ms
76,864 KB
testcase_14 AC 119 ms
77,308 KB
testcase_15 AC 121 ms
77,300 KB
testcase_16 AC 79 ms
73,960 KB
testcase_17 AC 117 ms
77,172 KB
testcase_18 AC 1,967 ms
137,268 KB
testcase_19 AC 253 ms
83,596 KB
testcase_20 AC 2,331 ms
149,664 KB
testcase_21 AC 2,190 ms
147,500 KB
testcase_22 AC 1,421 ms
123,260 KB
testcase_23 AC 851 ms
107,996 KB
testcase_24 AC 334 ms
87,468 KB
testcase_25 AC 2,054 ms
139,940 KB
testcase_26 AC 1,817 ms
131,432 KB
testcase_27 AC 2,037 ms
139,124 KB
testcase_28 AC 218 ms
81,888 KB
testcase_29 AC 1,841 ms
135,576 KB
testcase_30 AC 648 ms
97,240 KB
testcase_31 AC 2,336 ms
149,668 KB
testcase_32 AC 394 ms
88,980 KB
testcase_33 AC 633 ms
95,872 KB
testcase_34 AC 2,307 ms
150,176 KB
testcase_35 AC 2,357 ms
149,540 KB
testcase_36 AC 2,412 ms
151,328 KB
testcase_37 AC 1,115 ms
116,176 KB
testcase_38 AC 2,417 ms
146,472 KB
testcase_39 AC 2,414 ms
147,372 KB
testcase_40 AC 2,392 ms
146,472 KB
testcase_41 AC 1,983 ms
136,880 KB
testcase_42 AC 2,373 ms
146,464 KB
testcase_43 AC 2,078 ms
138,488 KB
testcase_44 AC 2,391 ms
147,244 KB
testcase_45 AC 1,831 ms
131,000 KB
testcase_46 AC 887 ms
104,016 KB
testcase_47 AC 2,463 ms
146,340 KB
testcase_48 AC 1,301 ms
145,552 KB
testcase_49 AC 2,415 ms
151,748 KB
testcase_50 AC 2,394 ms
152,288 KB
testcase_51 AC 2,388 ms
151,780 KB
testcase_52 AC 2,371 ms
152,168 KB
testcase_53 AC 342 ms
88,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = []
mi_max = 10**9
for i in range(N):
    if A[i]>B[i]:
        A[i],B[i]=B[i],A[i]
    C.append([A[i],(A[i]+B[i])//2,B[i]])
    mi_max = min(mi_max,B[i])
mi = 10**9
ma = 0
h = []
for i,a in enumerate(A):
    mi = min(mi,a)
    ma = max(ma,a)
    heapq.heappush(h,(a,i,0))
ans = ma-mi
while h:
    before,i,ii= heapq.heappop(h)
    if ii==0:
        heapq.heappush(h,((A[i]+B[i])//2,i,1))
        ma = max(ma,(A[i]+B[i])//2)
    if ii==1:
        ma = max(ma,B[i])
    if len(h):
        mi=min(h[0][0],mi_max)
    ans = min(ans,ma-mi)
print(ans)
0