結果

問題 No.2248 max(C)-min(C)
ユーザー rlangevinrlangevin
提出日時 2023-03-17 22:12:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,043 ms / 3,000 ms
コード長 829 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 148,392 KB
最終ジャッジ日時 2023-10-18 15:05:25
合計ジャッジ時間 55,296 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,536 KB
testcase_01 AC 40 ms
55,536 KB
testcase_02 AC 40 ms
55,536 KB
testcase_03 AC 56 ms
68,476 KB
testcase_04 AC 52 ms
66,384 KB
testcase_05 AC 49 ms
63,888 KB
testcase_06 AC 63 ms
72,964 KB
testcase_07 AC 64 ms
73,640 KB
testcase_08 AC 71 ms
76,348 KB
testcase_09 AC 72 ms
76,388 KB
testcase_10 AC 50 ms
63,888 KB
testcase_11 AC 71 ms
76,348 KB
testcase_12 AC 57 ms
68,488 KB
testcase_13 AC 61 ms
70,588 KB
testcase_14 AC 71 ms
76,380 KB
testcase_15 AC 71 ms
76,368 KB
testcase_16 AC 56 ms
68,476 KB
testcase_17 AC 66 ms
73,608 KB
testcase_18 AC 1,672 ms
148,012 KB
testcase_19 AC 218 ms
84,652 KB
testcase_20 AC 1,900 ms
140,328 KB
testcase_21 AC 1,834 ms
146,204 KB
testcase_22 AC 1,228 ms
137,984 KB
testcase_23 AC 776 ms
112,424 KB
testcase_24 AC 306 ms
90,968 KB
testcase_25 AC 1,731 ms
144,424 KB
testcase_26 AC 1,527 ms
137,192 KB
testcase_27 AC 1,712 ms
146,908 KB
testcase_28 AC 183 ms
81,880 KB
testcase_29 AC 1,583 ms
136,080 KB
testcase_30 AC 603 ms
95,300 KB
testcase_31 AC 1,897 ms
140,316 KB
testcase_32 AC 352 ms
91,424 KB
testcase_33 AC 556 ms
95,072 KB
testcase_34 AC 1,921 ms
140,416 KB
testcase_35 AC 1,918 ms
140,392 KB
testcase_36 AC 1,906 ms
140,324 KB
testcase_37 AC 955 ms
125,488 KB
testcase_38 AC 1,965 ms
139,876 KB
testcase_39 AC 1,997 ms
139,880 KB
testcase_40 AC 1,998 ms
139,876 KB
testcase_41 AC 1,681 ms
148,392 KB
testcase_42 AC 1,986 ms
139,880 KB
testcase_43 AC 1,734 ms
147,544 KB
testcase_44 AC 1,997 ms
139,620 KB
testcase_45 AC 1,540 ms
145,884 KB
testcase_46 AC 777 ms
100,240 KB
testcase_47 AC 1,999 ms
139,688 KB
testcase_48 AC 762 ms
146,848 KB
testcase_49 AC 2,007 ms
140,980 KB
testcase_50 AC 1,998 ms
140,980 KB
testcase_51 AC 2,001 ms
140,972 KB
testcase_52 AC 2,043 ms
140,976 KB
testcase_53 AC 328 ms
90,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
D = []
for i in range(N):
    D.append((A[i], i))
    D.append((B[i], i))
    D.append(((A[i] + B[i])//2, i))
    
D.sort(reverse=True)
cnt = 0
L = [0] * N
ans = 10 ** 18
Q = deque()
while D:
    now = D[-1][0]
    while D:
        if D[-1][0] == now:
            _, ind = D.pop()
            Q.append((ind, now))
            L[ind] += 1
            if L[ind] == 1:
                cnt += 1
        else:
            break
    
    while cnt == N:
        val = Q[0][1]
        ans = min(ans, abs(Q[0][1] - Q[-1][-1]))
        while Q[0][1] == val:
            ind, _ = Q.popleft()
            L[ind] -= 1
            if L[ind] == 0:
                cnt -= 1
            if not Q:
                break
print(ans)
0