結果

問題 No.2248 max(C)-min(C)
ユーザー 👑 H20H20
提出日時 2023-03-17 22:40:05
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 750 bytes
コンパイル時間 874 ms
コンパイル使用メモリ 81,348 KB
実行使用メモリ 243,648 KB
最終ジャッジ日時 2023-10-18 15:41:14
合計ジャッジ時間 81,292 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,452 KB
testcase_01 AC 43 ms
55,452 KB
testcase_02 AC 43 ms
55,452 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 TLE -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 2,980 ms
225,308 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 2,897 ms
225,716 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 2,229 ms
196,272 KB
testcase_46 WA -
testcase_47 AC 2,861 ms
225,984 KB
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
import collections
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = []
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 = 10**9
ma = 0
h = []
COL = collections.Counter()
for i,a in enumerate(A):
    mi = min(mi,a)
    ma = max(ma,a)
    heapq.heappush(h,(a,i,0))
    COL[a]+=1
ans = ma-mi
while h:
    before,i,ii= heapq.heappop(h)
    COL[before]-=1
    if ii==0:
        heapq.heappush(h,((A[i]+B[i])//2,i,1))
        ma = max(ma,(A[i]+B[i])//2)
        COL[(A[i]+B[i])//2]+=1
    if ii==1:
        ma = max(ma,B[i])
        COL[B[i]]+=1
    if COL[before]==0 and mi==before:
        mi=h[0][0]
    ans = min(ans,ma-mi)
print(ans)
0