結果

問題 No.1998 Manhattan Restaurant
ユーザー 👑 NachiaNachia
提出日時 2022-07-01 21:25:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 77,184 KB
実行使用メモリ 4,636 KB
最終ジャッジ日時 2023-08-17 08:35:42
合計ジャッジ時間 3,954 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 25 ms
4,620 KB
testcase_16 AC 14 ms
4,376 KB
testcase_17 AC 19 ms
4,376 KB
testcase_18 AC 15 ms
4,376 KB
testcase_19 AC 16 ms
4,380 KB
testcase_20 AC 25 ms
4,584 KB
testcase_21 AC 27 ms
4,584 KB
testcase_22 AC 28 ms
4,636 KB
testcase_23 AC 27 ms
4,556 KB
testcase_24 AC 27 ms
4,580 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 16 ms
4,380 KB
testcase_27 AC 11 ms
4,380 KB
testcase_28 AC 16 ms
4,380 KB
testcase_29 AC 11 ms
4,380 KB
testcase_30 AC 22 ms
4,544 KB
testcase_31 AC 20 ms
4,376 KB
testcase_32 AC 3 ms
4,376 KB
testcase_33 AC 14 ms
4,376 KB
testcase_34 AC 17 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i64 = long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N; cin >> N;
	vector<i64> X(N);
	vector<i64> Y(N);
	rep(i,N){
		int x,y; cin >> x >> y;
		X[i] = x+y; Y[i] = x-y;
	}

	i64 minX = X[0], maxX = X[0];
	i64 minY = Y[0], maxY = Y[0];
	rep(i, N){
		minX = min(minX, X[i]);
		maxX = max(maxX, X[i]);
		minY = min(minY, Y[i]);
		maxY = max(maxY, Y[i]);
	}
	for(auto& x : X) x -= minX;
	maxX -= minX;
	for(auto& y : Y) y -= minY;
	maxY -= minY;

	i64 ans = 1001001001001;

	rep(t,2){
		for(auto& x : X) x = maxX - x;
		i64 tmp = 0;
		rep(i,N){
			i64 cost1 = max(X[i], Y[i]);
			i64 cost2 = max(maxX - X[i], maxY - Y[i]);
			tmp = max(tmp, min(cost1,cost2));
		}
		ans = min(ans, tmp);
	}
    
    ans = (ans + 1) / 2;
	cout << ans << '\n';
	return 0;
}
0