結果
| 問題 |
No.2612 Close the Distance
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-01-19 23:19:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,514 bytes |
| コンパイル時間 | 3,985 ms |
| コンパイル使用メモリ | 261,612 KB |
| 最終ジャッジ日時 | 2025-02-18 21:32:44 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 24 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
bool check(vector<pair<long long,long long>> t,long long m){
set<pair<long long,pair<long long,long long>>> S;
int cur = 0;
rep(i,t.size()){
while(S.size()>0){
auto it = S.begin();
if((it->first) +m<= t[i].first)S.erase(it);
else break;
}
long long l = t[i].second - m,r = t[i].second;
auto it= S.begin();
while(it!=S.end()){
long long tl = (it->second).first;
long long tr = (it->second).second;
tl = max(tl,l);
tr = min(tr,r);
if(tl<=tr){
long long x = it->first;
S.erase(it);
S.emplace(x,make_pair(tl,tr));
break;
}
it++;
}
if(it==S.end()){
cur++;
if(cur>=4)return false;
S.emplace(t[i].first,make_pair(l,r));
}
}
return true;
}
int main(){
int n;
cin>>n;
vector t(4,vector<pair<long long,long long>>());
rep(i,n){
long long x,y;
cin>>x>>y;
t[0].emplace_back(x+y,x-y);
t[1].emplace_back(-(x+y),x-y);
t[2].emplace_back(x-y,x+y);
t[3].emplace_back(-(x-y),x+y);
}
rep(i,4)sort(t[i].begin(),t[i].end());
long long ok = 2000000005,ng = -1;
while(ok-ng>1LL){
long long mid = (ok+ng)/2;
bool f = false;
rep(i,4){
if(check(t[i],mid)){
f = true;
break;
}
}
if(f)ok = mid;
else ng = mid;
}
cout<<ok<<endl;
return 0;
}
沙耶花