結果
| 問題 | No.2248 max(C)-min(C) |
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-03-17 22:12:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,919 ms / 3,000 ms |
| コード長 | 829 bytes |
| コンパイル時間 | 222 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 148,276 KB |
| 最終ジャッジ日時 | 2024-09-18 11:18:43 |
| 合計ジャッジ時間 | 50,878 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 51 |
ソースコード
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)
rlangevin