結果

問題 No.1998 Manhattan Restaurant
ユーザー t98slidert98slider
提出日時 2022-07-02 20:17:24
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 965 bytes
コンパイル時間 3,520 ms
コンパイル使用メモリ 178,616 KB
実行使用メモリ 7,312 KB
最終ジャッジ日時 2023-08-18 12:21:54
合計ジャッジ時間 5,243 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 95 ms
6,952 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 95 ms
6,956 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

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(dist(i, pos1[0]), dist(i, pos1.back()));
        d[i] = min(dist(i, pos2[0]), dist(i, pos2.back()));
    }
    ll ans = *max_element(c.begin(), c.end());
    ans = min(ans, *max_element(d.begin(), d.end()));
    cout << ans / 2 << '\n';
}
0