結果

問題 No.2612 Close the Distance
ユーザー MitarushiMitarushi
提出日時 2024-01-06 13:20:12
言語 Nim
(2.2.0)
結果
AC  
実行時間 1,213 ms / 3,000 ms
コード長 1,555 bytes
コンパイル時間 3,612 ms
コンパイル使用メモリ 66,884 KB
実行使用メモリ 47,576 KB
最終ジャッジ日時 2024-09-28 05:14:08
合計ジャッジ時間 23,241 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

import strutils, sequtils
iterator readInt(): int {.closure.} =
while true:
let line = stdin.readLine.split.map(parseInt)
for x in line:
yield x
var input = readInt
let n = input()
var
x = newSeq[int64]()
y = newSeq[int64]()
for _ in 0..<n:
let (a, b) = (input(), input())
x.add(a + b)
y.add(b - a)
let xy = zip(x, y)
iterator exclude_box(xy: openArray[(int64, int64)], box_x, box_y, a: int64): (int64, int64) =
for (x, y) in xy:
if not (box_x <= x and x <= box_x + a and box_y <= y and y <= box_y + a):
yield (x, y)
proc is_not_more_than(xy: openArray[(int64, int64)], a, k: int64): bool =
if xy.len <= k:
return true
if k == 0:
return false
let
x_min = xy.mapIt(it[0]).min
x_max = xy.mapIt(it[0]).max
y_min = xy.mapIt(it[1]).min
y_max = xy.mapIt(it[1]).max
if is_not_more_than(exclude_box(xy, x_min, y_min, a).toSeq, a, k - 1):
return true
if k >= 2 and is_not_more_than(exclude_box(xy, x_min, y_max - a, a).toSeq, a, k - 1):
return true
if k >= 3 and is_not_more_than(exclude_box(xy, x_max - a, y_min, a).toSeq, a, k - 1):
return true
if k >= 3 and is_not_more_than(exclude_box(xy, x_max - a, y_max - a, a).toSeq, a, k - 1):
return true
false
let max_a = max(x.max - x.min, y.max - y.min)
var
ng = -1i64
ok = max_a
while ok - ng > 1:
let m = (ok + ng) div 2
if is_not_more_than(xy, m, 3):
ok = m
else:
ng = m
echo ok
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0