結果

問題 No.1998 Manhattan Restaurant
ユーザー t98slidert98slider
提出日時 2022-07-02 20:31:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,189 bytes
コンパイル時間 1,559 ms
コンパイル使用メモリ 178,576 KB
実行使用メモリ 7,220 KB
最終ジャッジ日時 2023-08-18 12:40:14
合計ジャッジ時間 5,805 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 87 ms
7,044 KB
testcase_16 AC 41 ms
5,184 KB
testcase_17 AC 57 ms
5,992 KB
testcase_18 AC 42 ms
5,184 KB
testcase_19 AC 47 ms
5,492 KB
testcase_20 AC 87 ms
6,988 KB
testcase_21 AC 101 ms
6,928 KB
testcase_22 AC 98 ms
7,220 KB
testcase_23 AC 97 ms
7,036 KB
testcase_24 AC 98 ms
7,028 KB
testcase_25 AC 6 ms
4,380 KB
testcase_26 AC 46 ms
5,408 KB
testcase_27 AC 30 ms
4,536 KB
testcase_28 AC 47 ms
5,460 KB
testcase_29 AC 31 ms
4,548 KB
testcase_30 AC 69 ms
6,728 KB
testcase_31 AC 63 ms
6,136 KB
testcase_32 AC 8 ms
4,376 KB
testcase_33 AC 40 ms
5,200 KB
testcase_34 AC 51 ms
5,656 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 dist1 = [&](int i, int j){
        return abs(a[i].first + a[i].second - (a[j].first + a[j].second));
    };
    auto dist2 = [&](int i, int j){
        return abs(a[i].first - a[i].second - (a[j].first - 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(dist1(i, pos1[0]), dist2(i, pos2[0])), max(dist1(i, pos1[n - 1]), dist2(i, pos2[n - 1])));
        d[i] = min(max(dist1(i, pos1[0]), dist2(i, pos2[n - 1])), max(dist1(i, pos1[n - 1]), dist2(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