結果
| 問題 | No.2248 max(C)-min(C) | 
| コンテスト | |
| ユーザー |  ikoma | 
| 提出日時 | 2023-03-18 01:09:58 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2,326 ms / 3,000 ms | 
| コード長 | 682 bytes | 
| コンパイル時間 | 337 ms | 
| コンパイル使用メモリ | 82,096 KB | 
| 実行使用メモリ | 172,552 KB | 
| 最終ジャッジ日時 | 2024-09-18 12:48:11 | 
| 合計ジャッジ時間 | 59,319 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 51 | 
ソースコード
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)
            
            
            
        