結果

問題 No.3759 Watch Fireworks
コンテスト
ユーザー ZeriToki
提出日時 2026-10-09 23:16:33
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 88 ms / 2,000 ms
+ 84µs
コード長 1,943 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,960 ms
コンパイル使用メモリ 339,400 KB
実行使用メモリ 9,848 KB
最終ジャッジ日時 2026-10-09 23:16:45
合計ジャッジ時間 6,081 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
const long long mod=998244353;
const long long mod2=469762049;
const long long mod100=1000000007;


struct Point{
    ll x,y;
};
bool operator<(const Point &a,const Point &b){
    if(a.x!=b.x) return a.x<b.x;
    return a.y<b.y;
}

ll dist(Point a,Point b){
    return max(abs(a.x-b.x),abs(a.y-b.y));
}

int main(){
    cout.tie()->sync_with_stdio(0);
    cin.tie(0);
    
    int N;cin>>N;
    Point P[N+1];
    for(int i=1;i<=N;i++){
        cin>>P[i].x>>P[i].y;
        ll a=P[i].x+P[i].y,b=P[i].x-P[i].y;
        P[i].x=a;
        P[i].y=b;
    }
    sort(P+1,P+N+1);
    Point dat[4];
    for(int i=0;i<4;i++) dat[i]=P[1];
    

    for(int i=1;i<=N;i++){
        chmin(dat[0].x,P[i].x);
        chmin(dat[1].x,P[i].x);
        chmax(dat[2].x,P[i].x);
        chmax(dat[3].x,P[i].x);

        chmin(dat[0].y,P[i].y);
        chmin(dat[2].y,P[i].y);
        chmax(dat[1].y,P[i].y);
        chmax(dat[3].y,P[i].y);
    }

    rep(i,4){
        //cout<<dat[i].x<<" "<<dat[i].y<<endl;
    }

    

    ll l=0,r=1e10;
    while(l!=r){
        ll m=(l+r)/2;
        bool check=false;
        for(int a=0;a<4;a++){
            for(int b=a+1;b<4;b++){
                bool f=true;
                for(int i=1;i<=N;i++){
                    ll d=min(dist(P[i],dat[a]),dist(P[i],dat[b]));
                    if(d>m){
                        f=false;
                        break;
                    }
                }
                if(f){
                    check=true;
                    break;
                }
            }
            if(check==true) break;
        }
        if(check) r=m;
        else l=m+1;
    }
    cout<<l<<endl;
}
0