結果

問題 No.2248 max(C)-min(C)
ユーザー titiatitia
提出日時 2023-03-17 21:52:15
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 546 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 143,600 KB
最終ジャッジ日時 2024-09-18 10:45:21
合計ジャッジ時間 85,816 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36 TLE * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import heappop,heappush,heapify


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

X=[]

for i in range(N):
    Y=[A[i],B[i],(A[i]+B[i])//2]
    Y.sort()
    X.append(tuple(Y))

ANS=1<<60

MAX=0
for x in X:
    MAX=max(MAX,x[0])

heapify(X)
MIN=1<<60

while X:
    k=list(heappop(X))

    ANS=min(ANS,MAX-min(MIN,k[0]))

    u=k.pop(0)

    if len(k)==0:
        MIN=min(MIN,u)
        
    else:
        heappush(X,tuple(k))
        MAX=max(MAX,k[0])

print(ANS)
0