結果

問題 No.2248 max(C)-min(C)
ユーザー hir355hir355
提出日時 2023-03-17 22:41:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,388 ms / 3,000 ms
コード長 646 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 81,624 KB
実行使用メモリ 145,624 KB
最終ジャッジ日時 2023-10-18 15:42:17
合計ジャッジ時間 33,173 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,400 KB
testcase_01 AC 38 ms
53,400 KB
testcase_02 AC 38 ms
53,400 KB
testcase_03 AC 49 ms
61,900 KB
testcase_04 AC 44 ms
59,640 KB
testcase_05 AC 42 ms
58,976 KB
testcase_06 AC 57 ms
66,620 KB
testcase_07 AC 58 ms
66,636 KB
testcase_08 AC 61 ms
68,712 KB
testcase_09 AC 58 ms
66,636 KB
testcase_10 AC 42 ms
58,976 KB
testcase_11 AC 58 ms
66,636 KB
testcase_12 AC 46 ms
61,828 KB
testcase_13 AC 56 ms
66,620 KB
testcase_14 AC 58 ms
66,636 KB
testcase_15 AC 61 ms
68,712 KB
testcase_16 AC 46 ms
61,900 KB
testcase_17 AC 59 ms
66,644 KB
testcase_18 AC 237 ms
107,760 KB
testcase_19 AC 78 ms
79,816 KB
testcase_20 AC 268 ms
132,216 KB
testcase_21 AC 275 ms
132,288 KB
testcase_22 AC 201 ms
102,156 KB
testcase_23 AC 154 ms
97,476 KB
testcase_24 AC 90 ms
83,356 KB
testcase_25 AC 242 ms
107,492 KB
testcase_26 AC 242 ms
105,592 KB
testcase_27 AC 232 ms
107,640 KB
testcase_28 AC 77 ms
78,316 KB
testcase_29 AC 237 ms
107,976 KB
testcase_30 AC 129 ms
94,448 KB
testcase_31 AC 276 ms
132,220 KB
testcase_32 AC 95 ms
84,964 KB
testcase_33 AC 126 ms
92,260 KB
testcase_34 AC 297 ms
132,408 KB
testcase_35 AC 293 ms
132,316 KB
testcase_36 AC 277 ms
132,276 KB
testcase_37 AC 162 ms
98,480 KB
testcase_38 AC 1,584 ms
127,600 KB
testcase_39 AC 1,624 ms
127,804 KB
testcase_40 AC 1,664 ms
127,628 KB
testcase_41 AC 1,376 ms
122,180 KB
testcase_42 AC 1,644 ms
127,632 KB
testcase_43 AC 1,403 ms
124,104 KB
testcase_44 AC 1,611 ms
128,516 KB
testcase_45 AC 1,230 ms
117,816 KB
testcase_46 AC 632 ms
99,596 KB
testcase_47 AC 1,641 ms
127,788 KB
testcase_48 AC 1,329 ms
140,752 KB
testcase_49 AC 2,346 ms
145,604 KB
testcase_50 AC 2,388 ms
145,584 KB
testcase_51 AC 2,307 ms
145,624 KB
testcase_52 AC 2,289 ms
145,552 KB
testcase_53 AC 332 ms
85,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n):
    if a[i] > b[i]:
        a[i], b[i] = b[i], a[i]
hq = []
for i in range(n):
    heapq.heappush(hq, (a[i], i, 0))
ma = max(a)
ans = max(a) - min(a)
for _ in range(n * 2):
    x, i, j = heapq.heappop(hq)
    if ans > ma - x:
        ans = ma - x
    if j == 0:
        heapq.heappush(hq, ((a[i] + b[i]) // 2, i, 1))
        if ma < (a[i] + b[i]) // 2:
            ma = (a[i] + b[i]) // 2
    elif j == 1:
        heapq.heappush(hq, (b[i], i, 2))
        if ma < b[i]:
            ma = b[i]
    else:
        break
print(ans)
0