結果

問題 No.2248 max(C)-min(C)
ユーザー titiatitia
提出日時 2023-03-17 22:03:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,361 ms / 3,000 ms
コード長 578 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 81,316 KB
実行使用メモリ 141,628 KB
最終ジャッジ日時 2023-10-18 14:49:12
合計ジャッジ時間 41,819 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,164 KB
testcase_01 AC 40 ms
53,164 KB
testcase_02 AC 38 ms
53,164 KB
testcase_03 AC 46 ms
59,144 KB
testcase_04 AC 44 ms
59,144 KB
testcase_05 AC 40 ms
53,164 KB
testcase_06 AC 53 ms
63,952 KB
testcase_07 AC 50 ms
63,952 KB
testcase_08 AC 53 ms
63,976 KB
testcase_09 AC 51 ms
63,952 KB
testcase_10 AC 40 ms
53,164 KB
testcase_11 AC 51 ms
63,952 KB
testcase_12 AC 46 ms
61,192 KB
testcase_13 AC 52 ms
63,976 KB
testcase_14 AC 51 ms
63,952 KB
testcase_15 AC 53 ms
63,976 KB
testcase_16 AC 45 ms
59,144 KB
testcase_17 AC 52 ms
63,952 KB
testcase_18 AC 640 ms
106,816 KB
testcase_19 AC 105 ms
79,800 KB
testcase_20 AC 733 ms
130,352 KB
testcase_21 AC 707 ms
131,000 KB
testcase_22 AC 476 ms
103,256 KB
testcase_23 AC 308 ms
95,588 KB
testcase_24 AC 141 ms
83,016 KB
testcase_25 AC 677 ms
106,464 KB
testcase_26 AC 589 ms
105,192 KB
testcase_27 AC 653 ms
106,468 KB
testcase_28 AC 98 ms
78,500 KB
testcase_29 AC 615 ms
107,844 KB
testcase_30 AC 265 ms
92,876 KB
testcase_31 AC 734 ms
130,356 KB
testcase_32 AC 154 ms
84,216 KB
testcase_33 AC 231 ms
90,404 KB
testcase_34 AC 757 ms
130,432 KB
testcase_35 AC 745 ms
130,400 KB
testcase_36 AC 734 ms
130,360 KB
testcase_37 AC 377 ms
101,304 KB
testcase_38 AC 1,746 ms
125,452 KB
testcase_39 AC 1,752 ms
124,948 KB
testcase_40 AC 1,774 ms
125,488 KB
testcase_41 AC 1,501 ms
118,460 KB
testcase_42 AC 1,757 ms
125,492 KB
testcase_43 AC 1,574 ms
120,268 KB
testcase_44 AC 1,791 ms
124,676 KB
testcase_45 AC 1,348 ms
113,256 KB
testcase_46 AC 695 ms
98,080 KB
testcase_47 AC 1,738 ms
124,984 KB
testcase_48 AC 1,420 ms
134,148 KB
testcase_49 AC 2,340 ms
141,628 KB
testcase_50 AC 2,289 ms
141,624 KB
testcase_51 AC 2,360 ms
141,112 KB
testcase_52 AC 2,361 ms
141,572 KB
testcase_53 AC 352 ms
85,044 KB
権限があれば一括ダウンロードができます

ソースコード

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<<31

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

X.sort()
MIN=1<<31

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

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

    if MIN!=1<<31:
        break

    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