結果
| 問題 |
No.2157 崖
|
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2022-12-09 22:52:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 783 bytes |
| コンパイル時間 | 204 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 153,136 KB |
| 最終ジャッジ日時 | 2024-10-14 22:40:30 |
| 合計ジャッジ時間 | 15,269 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 TLE * 1 -- * 10 |
ソースコード
import bisect
import itertools
def is_ok(v):
S = D[0]
for ND in D[1:]:
IMOS = [0]*(len(ND)+1)
for s in S:
l = bisect.bisect_left(ND,s)
r = bisect.bisect_right(ND,s+v)
IMOS[l]+=1
IMOS[r]-=1
NS = []
L = list(itertools.accumulate(IMOS))
for j,l in enumerate(L):
if l>0 and j<len(ND):
NS.append(ND[j])
S = NS
return S
N,M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N)]
D = []
for l in L:
D.append(sorted(list(set(l))))
ng = -1
ok = 10**9+100
while (abs(ok - ng) > 1):
mid = (ok + ng) // 2
if is_ok(mid):
ok = mid
else:
ng = mid
if ok == 10**9+100:
print(-1)
else:
print(ok)
H20