結果

問題 No.2612 Close the Distance
ユーザー 沙耶花沙耶花
提出日時 2024-01-19 23:19:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,514 bytes
コンパイル時間 4,467 ms
コンパイル使用メモリ 276,140 KB
実行使用メモリ 19,216 KB
最終ジャッジ日時 2024-01-19 23:19:46
合計ジャッジ時間 25,526 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0