結果

問題 No.3759 Watch Fireworks
コンテスト
ユーザー shingo0909
提出日時 2026-10-09 22:28:17
言語 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  
実行時間 61 ms / 2,000 ms
+ 118µs
コード長 1,431 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,024 ms
コンパイル使用メモリ 335,652 KB
実行使用メモリ 9,900 KB
最終ジャッジ日時 2026-10-09 22:28:27
合計ジャッジ時間 6,053 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        a *= 2;
        b *= 2;
        x[i] = a + b;
        y[i] = a - b;
    }
    ll l = 1LL << 60;
    ll u = 1LL << 60;
    ll d = -1LL << 60;
    ll r = -1LL << 60;
    for (ll i : x) {
        l = min(l, i);
        r = max(r, i);
    }
    for (ll i : y) {
        u = min(u, i);
        d = max(d, i);
    }
    if (n <= 2) {
        cout << 0 << endl;
        return 0;
    }
    ll L = 0, R = 1LL << 60;

    while (L + 1 != R) {
        ll c = (L + R) / 2;
        auto check = [&](ll x1, ll y1, ll x2, ll y2) {
            rep(i, n) {
                bool ok = false;
                if (x1 <= x[i] && x[i] <= x1 + 2 * c && y1 <= y[i] && y[i] <= y1 + 2 * c)
                    ok = true;
                if (x2 <= x[i] && x[i] <= x2 + 2 * c && y2 <= y[i] && y[i] <= y2 + 2 * c)
                    ok = true;
                if (!ok)
                    return false;
            }
            return true;
        };
        if (check(l, u, r - 2 * c, d - 2 * c) || check(l, d - 2 * c, r - 2 * c, u)) {
            R = c;
        } else {
            L = c;
        }
    }
    cout << R << endl;
    return 0;
}
0