結果
| 問題 | No.1997 X Lighting | 
| コンテスト | |
| ユーザー |  MasKoaTS | 
| 提出日時 | 2022-02-20 16:23:15 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 1,420 bytes | 
| コンパイル時間 | 791 ms | 
| コンパイル使用メモリ | 80,024 KB | 
| 最終ジャッジ日時 | 2025-01-28 01:10:44 | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 2 RE * 1 | 
| other | WA * 8 RE * 22 | 
ソースコード
#include <iostream>
#include <vector>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define chmin(x, y) if(x > (y)){ x = (y); }
#define chmax(x, y) if(x < (y)){ x = (y); }
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T> >;
int N;
ll max_x, max_y, min_x, min_y;
bool func(VV<ll>&P, ll k) {
	k *= 2;
	VV<int> block = { {0,0},{0,0} };
	for (auto& p : P) {
		ll x = p[0], y = p[1];
		if ((x < max_x - k and x > min_x + k) or (y < max_y - k and y > min_y + k)) {
			return false;
		}
		if (x < max_x - k and y < max_y - k) {
			block[0][0] = 1;
		}
		if (x > min_x + k and y < max_y - k) {
			block[1][0] = 1;
		}
		if (x < max_x - k and y > min_y + k) {
			block[0][1] = 1;
		}
		if (x > min_x + k and y > min_y + k) {
			block[1][1] = 1;
		}
	}
	if ((block[0][0] | block[1][1]) == 0 or (block[0][1] | block[1][0]) == 0) {
		return true;
	}
	return false;
}
int main(void) {
	cin >> N;
	VV<ll> P(N, V<ll>(2));
	rep(i, 0, N) {
		ll x, y;	cin >> x >> y;
		P[i] = { x + y,x - y };
	}
	max_x = min_x = P[0][0];
	max_y = min_y = P[0][1];
	rep(i, 1, N) {
		chmax(max_x, P[i][0]);	chmax(max_y, P[i][1]);
		chmin(min_x, P[i][0]);	chmin(min_y, P[i][1]);
	}
	ll ok = 2000000001, ng = -1;
	while (ok - ng > 1) {
		ll k = (ok + ng) / 2;
		if (func(P, k)) {
			ok = k;
		}
		else {
			ng = k;
		}
	}
	ll ans = ok;
	cout << ans << endl;
	return 0;
}
            
            
            
        