提出 #16806581


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define INF 1000000001
using lli = long long int;
using P = pair<lli, lli>;

bool invalid(P& p) {
  return (p.first == -1) || (p.second == -1) || (p.first == INF) || (p.second == INF);
}


lli dist(P& p, P& q) {
  if (invalid(p) || invalid(q)) return 0LL;
  return abs(p.first - q.first) + abs(p.second - q.second);
}

int main() {
  int N; cin >> N;

  P mx(INF, INF), Mx(-1, -1);
  P my(INF, INF), My(-1, -1);

  lli x, y;
  REP(n, N) {
    cin >> x >> y;
    mx = min(mx, {x, y});
    Mx = max(Mx, {x, y});
    my = min(my, {y, x});
    My = max(My, {y, x});
  }
  my = P{my.second, my.first};
  My = P{My.second, My.first};

  cout << max({ dist(mx, Mx), dist(mx, My), dist(my, Mx), dist(my, My), dist(mx, my), dist(Mx, My) }) << endl;

  return 0;
}

提出情報

提出日時
問題 E - Dist Max
ユーザ ryo_ryo66
言語 C++ (GCC 9.2.1)
得点 0
コード長 892 Byte
結果 WA
実行時間 118 ms
メモリ 3600 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 500
結果
AC × 2
AC × 7
WA × 11
セット名 テストケース
Sample sample00, sample01
All handmade02, handmade03, handmade04, handmade05, handmade06, handmade07, handmade08, handmade09, random07, random08, random09, random10, random11, random12, random13, random14, sample00, sample01
ケース名 結果 実行時間 メモリ
handmade02 AC 7 ms 3520 KiB
handmade03 AC 2 ms 3560 KiB
handmade04 AC 2 ms 3532 KiB
handmade05 AC 59 ms 3432 KiB
handmade06 AC 114 ms 3564 KiB
handmade07 WA 114 ms 3504 KiB
handmade08 WA 116 ms 3520 KiB
handmade09 WA 110 ms 3600 KiB
random07 WA 112 ms 3368 KiB
random08 WA 113 ms 3304 KiB
random09 WA 112 ms 3516 KiB
random10 WA 118 ms 3532 KiB
random11 WA 113 ms 3524 KiB
random12 WA 114 ms 3512 KiB
random13 WA 116 ms 3560 KiB
random14 WA 79 ms 3380 KiB
sample00 AC 2 ms 3476 KiB
sample01 AC 2 ms 3428 KiB