結果

問題 No.1998 Manhattan Restaurant
ユーザー milanis48663220
提出日時 2022-07-01 22:53:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 2,810 bytes
コンパイル時間 1,357 ms
コンパイル使用メモリ 121,856 KB
最終ジャッジ日時 2025-01-30 03:21:53
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

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

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
return vector<vector<T>>(n, vector<T>(m, v));
}
template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}
template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
if(v.empty()) {
cout << endl;
return;
}
for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
cout << v.back() << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int n; cin >> n;
vector<ll> x(n), y(n);
for(int i = 0; i < n; i++){
ll X, Y; cin >> X >> Y;
x[i] = X+Y;
y[i] = X-Y;
}
ll x_min = *min_element(x.begin(), x.end());
ll x_max = *max_element(x.begin(), x.end());
ll y_min = *min_element(y.begin(), y.end());
ll y_max = *max_element(y.begin(), y.end());
auto ok = [&](ll d) -> bool{
vector<bool> ok(n);
auto in_upper = [&](ll x){
return x_min <= x && x <= x_min+d*2;
};
auto in_lower = [&](ll x){
return x_max-2*d <= x && x <= x_max;
};
auto in_left = [&](ll y){
return y_min <= y && y <= y_min+d*2;
};
auto in_right = [&](ll y){
return y_max-2*d <= y && y <= y_max;
};
int ok_sum = 0;
for(int i = 0; i < n; i++){
if(in_upper(x[i]) && in_left(y[i])) ok[i] = true;
if(in_lower(x[i]) && in_right(y[i])) ok[i] = true;
if(ok[i]) ok_sum++;
}
if(ok_sum == n) return true;
ok.assign(n, false);
for(int i = 0; i < n; i++){
if(in_upper(x[i]) && in_right(y[i])) ok[i] = true;
if(in_lower(x[i]) && in_left(y[i])) ok[i] = true;
if(!ok[i]) return false;
}
return true;
};
if(ok(0)){
cout << 0 << endl;
return 0;
}
ll l = 0, r = 1e10;
while(r-l > 1){
ll d = (l+r)/2;
if(ok(d)) r = d;
else l = d;
}
cout << r << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0