結果

問題 No.1998 Manhattan Restaurant
ユーザー t98slidert98slider
提出日時 2022-07-02 20:24:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,065 bytes
コンパイル時間 1,981 ms
コンパイル使用メモリ 178,808 KB
実行使用メモリ 7,224 KB
最終ジャッジ日時 2023-08-18 12:30:41
合計ジャッジ時間 5,105 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 47 ms
5,132 KB
testcase_17 AC 66 ms
6,016 KB
testcase_18 AC 49 ms
5,200 KB
testcase_19 AC 55 ms
5,408 KB
testcase_20 WA -
testcase_21 AC 110 ms
7,224 KB
testcase_22 AC 110 ms
6,988 KB
testcase_23 AC 111 ms
6,944 KB
testcase_24 AC 111 ms
6,940 KB
testcase_25 AC 7 ms
4,380 KB
testcase_26 AC 53 ms
5,420 KB
testcase_27 AC 35 ms
4,700 KB
testcase_28 AC 54 ms
5,384 KB
testcase_29 AC 37 ms
4,616 KB
testcase_30 AC 78 ms
6,612 KB
testcase_31 AC 72 ms
6,188 KB
testcase_32 AC 10 ms
4,380 KB
testcase_33 AC 46 ms
5,088 KB
testcase_34 AC 58 ms
5,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int n;
    cin >> n;
    vector<pair<ll,ll>> a(n);
    for(auto &&p:a)cin >> p.first >> p.second;
    auto dist = [&](int i, int j){
        return abs(a[i].first - a[j].first) + abs(a[i].second - a[j].second);
    };
    vector<int> pos1(n), pos2;
    iota(pos1.begin(), pos1.end(), 0);
    pos2 = pos1;
    sort(pos1.begin(), pos1.end(), [&](int i, int j){
        return a[i].first + a[i].second < a[j].first + a[j].second;
    });
    sort(pos2.begin(), pos2.end(), [&](int i, int j){
        return a[i].first - a[i].second < a[j].first - a[j].second;
    });
    vector<ll> c(n), d(n);
    for(int i = 0; i < n; i++){
        c[i] = min(max(dist(i, pos1[0]), dist(i, pos2[0])), max(dist(i, pos1[n - 1]), dist(i, pos2[n - 1])));
        d[i] = min(max(dist(i, pos1[0]), dist(i, pos2[n - 1])), max(dist(i, pos1[n - 1]), dist(i, pos2[0])));
    }
    ll ans = *max_element(c.begin(), c.end());
    ans = min(ans, *max_element(d.begin(), d.end()));
    cout << ans / 2 << '\n';
}
0