結果
| 問題 |
No.2157 崖
|
| コンテスト | |
| ユーザー |
kemuniku
|
| 提出日時 | 2022-12-09 23:32:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,106 bytes |
| コンパイル時間 | 443 ms |
| コンパイル使用メモリ | 81,852 KB |
| 実行使用メモリ | 114,176 KB |
| 最終ジャッジ日時 | 2024-10-14 23:04:28 |
| 合計ジャッジ時間 | 15,180 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 TLE * 2 -- * 9 |
ソースコード
#https://aotamasaki.hatenablog.com/entry/meguru_bisect
import bisect
def is_ok(arg):
now = D[0]
for i in range(1,N):
next = []
for j in range(M):
ind = bisect.bisect(now,D[i][j])
if ind != 0:
if D[i][j]-now[ind-1] <= arg:
next.append(D[i][j])
elif ind == len(now):
break
now = next
if len(now) == 0:
return False
return True
def meguru_bisect(ng, ok):
'''
初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
まずis_okを定義すべし
ng ok は とり得る最小の値-1 とり得る最大の値+1
最大最小が逆の場合はよしなにひっくり返す
'''
while (abs(ok - ng) > 1):
mid = (ok + ng) // 2
if is_ok(mid):
ok = mid
else:
ng = mid
return ok
N,M = map(int,input().split())
D = [list(sorted(list(map(int,input().split())))) for i in range(N)]
x = meguru_bisect(-1,10**9+1)
if x == 10**9+1:
print(-1)
else:
print(x)
kemuniku