結果

問題 No.2248 max(C)-min(C)
ユーザー 👑 colognecologne
提出日時 2023-03-21 13:58:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,356 ms / 3,000 ms
コード長 542 bytes
コンパイル時間 477 ms
コンパイル使用メモリ 81,796 KB
実行使用メモリ 166,112 KB
最終ジャッジ日時 2023-10-18 18:25:12
合計ジャッジ時間 33,273 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,584 KB
testcase_01 AC 39 ms
53,584 KB
testcase_02 AC 39 ms
53,584 KB
testcase_03 AC 46 ms
61,796 KB
testcase_04 AC 42 ms
59,336 KB
testcase_05 AC 39 ms
53,584 KB
testcase_06 AC 57 ms
66,508 KB
testcase_07 AC 56 ms
68,564 KB
testcase_08 AC 58 ms
68,584 KB
testcase_09 AC 58 ms
68,564 KB
testcase_10 AC 41 ms
53,584 KB
testcase_11 AC 57 ms
68,564 KB
testcase_12 AC 46 ms
61,724 KB
testcase_13 AC 57 ms
66,528 KB
testcase_14 AC 59 ms
68,564 KB
testcase_15 AC 62 ms
68,596 KB
testcase_16 AC 47 ms
61,796 KB
testcase_17 AC 58 ms
68,568 KB
testcase_18 AC 305 ms
134,048 KB
testcase_19 AC 90 ms
80,660 KB
testcase_20 AC 342 ms
147,000 KB
testcase_21 AC 341 ms
143,868 KB
testcase_22 AC 240 ms
104,172 KB
testcase_23 AC 173 ms
95,836 KB
testcase_24 AC 103 ms
84,900 KB
testcase_25 AC 310 ms
136,460 KB
testcase_26 AC 298 ms
124,640 KB
testcase_27 AC 301 ms
136,064 KB
testcase_28 AC 80 ms
78,828 KB
testcase_29 AC 299 ms
131,164 KB
testcase_30 AC 155 ms
94,776 KB
testcase_31 AC 345 ms
146,996 KB
testcase_32 AC 111 ms
86,792 KB
testcase_33 AC 144 ms
94,316 KB
testcase_34 AC 374 ms
147,296 KB
testcase_35 AC 362 ms
147,152 KB
testcase_36 AC 349 ms
146,996 KB
testcase_37 AC 203 ms
99,736 KB
testcase_38 AC 1,621 ms
137,348 KB
testcase_39 AC 1,600 ms
137,348 KB
testcase_40 AC 1,563 ms
137,024 KB
testcase_41 AC 1,319 ms
119,196 KB
testcase_42 AC 1,552 ms
136,476 KB
testcase_43 AC 1,371 ms
119,984 KB
testcase_44 AC 1,586 ms
137,428 KB
testcase_45 AC 1,207 ms
115,572 KB
testcase_46 AC 604 ms
100,816 KB
testcase_47 AC 1,571 ms
137,452 KB
testcase_48 AC 1,424 ms
149,948 KB
testcase_49 AC 2,356 ms
166,112 KB
testcase_50 AC 2,326 ms
165,084 KB
testcase_51 AC 2,271 ms
164,576 KB
testcase_52 AC 2,284 ms
165,012 KB
testcase_53 AC 329 ms
85,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq


def main():
    N = int(input())
    *A, = map(int, input().split())
    *B, = map(int, input().split())
    Q = []
    for i in range(N):
        heapq.heappush(Q, sorted([A[i], B[i], (A[i]+B[i])//2]))
    mx, mn = max(Q)[0], Q[0][0]
    ans = mx-mn
    while True:
        a = heapq.heappop(Q)
        if len(a) == 1:
            print(ans)
            return
        a = a[1:]
        mx = max(mx, a[0])
        heapq.heappush(Q, a)
        mn = Q[0][0]
        ans = min(ans, mx-mn)


if __name__ == '__main__':
    main()
0