結果

問題 No.2248 max(C)-min(C)
ユーザー roarisroaris
提出日時 2023-03-17 23:50:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,131 ms / 3,000 ms
コード長 679 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 81,524 KB
実行使用メモリ 151,376 KB
最終ジャッジ日時 2023-10-18 16:38:47
合計ジャッジ時間 23,046 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
55,408 KB
testcase_01 AC 43 ms
55,408 KB
testcase_02 AC 43 ms
55,408 KB
testcase_03 AC 68 ms
63,804 KB
testcase_04 AC 50 ms
61,376 KB
testcase_05 AC 46 ms
55,408 KB
testcase_06 AC 66 ms
70,584 KB
testcase_07 AC 65 ms
70,576 KB
testcase_08 AC 67 ms
70,600 KB
testcase_09 AC 67 ms
70,584 KB
testcase_10 AC 46 ms
55,408 KB
testcase_11 AC 66 ms
70,584 KB
testcase_12 AC 53 ms
63,744 KB
testcase_13 AC 64 ms
68,528 KB
testcase_14 AC 67 ms
70,576 KB
testcase_15 AC 71 ms
72,664 KB
testcase_16 AC 53 ms
63,808 KB
testcase_17 AC 68 ms
70,592 KB
testcase_18 AC 337 ms
146,452 KB
testcase_19 AC 98 ms
83,524 KB
testcase_20 AC 374 ms
150,812 KB
testcase_21 AC 406 ms
151,376 KB
testcase_22 AC 282 ms
124,096 KB
testcase_23 AC 203 ms
106,008 KB
testcase_24 AC 119 ms
87,924 KB
testcase_25 AC 349 ms
146,428 KB
testcase_26 AC 326 ms
126,312 KB
testcase_27 AC 339 ms
146,136 KB
testcase_28 AC 94 ms
80,716 KB
testcase_29 AC 337 ms
145,864 KB
testcase_30 AC 182 ms
96,520 KB
testcase_31 AC 377 ms
151,372 KB
testcase_32 AC 148 ms
89,072 KB
testcase_33 AC 161 ms
90,716 KB
testcase_34 AC 391 ms
151,104 KB
testcase_35 AC 391 ms
150,548 KB
testcase_36 AC 380 ms
150,896 KB
testcase_37 AC 232 ms
115,332 KB
testcase_38 AC 879 ms
136,284 KB
testcase_39 AC 860 ms
135,756 KB
testcase_40 AC 850 ms
136,020 KB
testcase_41 AC 777 ms
132,132 KB
testcase_42 AC 877 ms
135,760 KB
testcase_43 AC 804 ms
131,536 KB
testcase_44 AC 883 ms
135,512 KB
testcase_45 AC 689 ms
129,888 KB
testcase_46 AC 417 ms
100,668 KB
testcase_47 AC 879 ms
136,284 KB
testcase_48 AC 605 ms
135,988 KB
testcase_49 AC 1,090 ms
149,320 KB
testcase_50 AC 1,123 ms
149,588 KB
testcase_51 AC 1,114 ms
150,380 KB
testcase_52 AC 1,131 ms
149,584 KB
testcase_53 AC 229 ms
87,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *
from heapq import *

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [(A[i]+B[i])//2 for i in range(N)]
ms = A+B+C
ms.sort()
L = [[A[i], B[i], C[i]] for i in range(N)]

for i in range(N):
    L[i].sort(reverse=True)
    
pq = []
M = 0

for i in range(N):
    M = max(M, L[i][-1])
    heappush(pq, (L[i].pop(), i))

ans = 10**18

for m in ms:
    while pq[0][0]<m:
        _, i = heappop(pq)
        
        if len(L[i])==0:
            exit(print(ans))
        
        M = max(M, L[i][-1])
        heappush(pq, (L[i].pop(), i))
    
    ans = min(ans, M-m)

print(ans)
0