結果

問題 No.3759 Watch Fireworks
コンテスト
ユーザー ei1333333
提出日時 2026-10-03 15:47:24
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,402 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,616 ms
コンパイル使用メモリ 366,932 KB
実行使用メモリ 18,160 KB
最終ジャッジ日時 2026-10-09 20:51:28
合計ジャッジ時間 6,884 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

using namespace std;

constexpr int inf = (1 << 30) - 1;

int main() {
  int N;
  cin >> N;
  vector< pair< int, int > > P(N);
  int x_min = inf, y_min = inf, x_max = -inf, y_max = -inf;
  for (auto& [x, y] : P) {
    int a, b;
    cin >> a >> b;
    x = a + b;
    y = a - b;
    x_min = min(x_min, x);
    x_max = max(x_max, x);
    y_min = min(y_min, y);
    y_max = max(y_max, y);
  }
  int ret = inf * 2;
  for (auto x : {x_min, x_max}) {
    for (auto y : {y_min, y_max}) {
      vector< tuple< int, int, int > > vs;
      for (auto& [a, b]: P) {
        vs.emplace_back(max(abs(a - x), abs(b - y)), a, b);
      }
      ranges::sort(vs);
      int a_min = inf, a_max = -inf, b_min = inf, b_max = -inf;
      vector score {0};
      for (auto& [d, a, b]: vs) {
        a_min = min(a_min, a);
        a_max = max(a_max, a);
        b_min = min(b_min, b);
        b_max = max(b_max, b);
        score.emplace_back(max(a_max - a_min, b_max - b_min));
      }
      a_min = inf, a_max = -inf, b_min = inf, b_max = -inf;
      ret = min(ret, score.back());
      for (auto& [d, a, b]: vs | views::reverse) {
        a_min = min(a_min, a);
        a_max = max(a_max, a);
        b_min = min(b_min, b);
        b_max = max(b_max, b);
        score.pop_back();
        ret = min(ret, max({a_max - a_min, b_max - b_min, score.back()}));
      }
    }
  }
  cout << ret << endl;
}
0