結果

問題 No.3325 陰陽師
コンテスト
ユーザー Prala
提出日時 2025-11-01 15:42:50
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,113 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 350 ms
コンパイル使用メモリ 82,628 KB
実行使用メモリ 69,916 KB
最終ジャッジ日時 2025-11-01 15:42:55
合計ジャッジ時間 4,304 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
sys.setrecursionlimit(5*10**7)
import math
import bisect
import heapq
from collections import deque, defaultdict 
import random
import itertools
#from decimal import Decimal
#from copy import copy, deepcopy
from sortedcontainers import SortedList

# -------------------------------------------------
pin = sys.stdin.readline
def ST(): return pin().rstrip()
def IN(): return int(pin())
def IM(): return map(int, pin().split())
def IL(): return list(IM())
def SR(n:int)->list: return [pin().rstrip() for _ in range(n)]
def IMatrix(n:int)->list: return [IL() for _ in range(n)]

INF = 2*10**18+1
mod = 998244353
# -------------------------------------------------
#import pypyjit
#pypyjit.set_param("max_unroll_recursion=-1")

N, M = IM()
S = IL() + [INF]
T = IL()

S.sort()
sT = sorted(T)
d = defaultdict(deque)

j = 0
for i in range(M):
    if j >= N:
        break
    t = sT[i]
    while S[j] < t:
        j += 1
    if j != N:
        d[t].append(S[j])
    j += 1
    
ans = 0
for i in range(M):
    t = T[i]
    if not d[t]:
        break
    c = d[t].popleft()
    ans = max(ans, c-t)

print(ans)

0