結果

問題 No.2261 Coffee
ユーザー CoCo_Japan_panCoCo_Japan_pan
提出日時 2023-04-07 23:10:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 1,500 bytes
コンパイル時間 2,234 ms
コンパイル使用メモリ 199,696 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-04-10 17:59:24
合計ジャッジ時間 7,730 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 5 ms
6,940 KB
testcase_18 AC 6 ms
6,944 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 5 ms
6,940 KB
testcase_22 AC 5 ms
6,940 KB
testcase_23 AC 5 ms
6,940 KB
testcase_24 AC 144 ms
24,960 KB
testcase_25 AC 114 ms
22,016 KB
testcase_26 AC 148 ms
26,544 KB
testcase_27 AC 134 ms
24,832 KB
testcase_28 AC 76 ms
22,912 KB
testcase_29 AC 72 ms
22,400 KB
testcase_30 AC 58 ms
18,304 KB
testcase_31 AC 101 ms
26,536 KB
testcase_32 AC 96 ms
26,644 KB
testcase_33 AC 97 ms
26,496 KB
testcase_34 AC 98 ms
26,624 KB
testcase_35 AC 95 ms
26,744 KB
testcase_36 AC 96 ms
26,688 KB
testcase_37 AC 95 ms
26,524 KB
testcase_38 AC 148 ms
26,624 KB
testcase_39 AC 146 ms
26,752 KB
testcase_40 AC 150 ms
26,484 KB
testcase_41 AC 152 ms
26,704 KB
testcase_42 AC 146 ms
26,624 KB
testcase_43 AC 146 ms
26,624 KB
testcase_44 AC 148 ms
26,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 提出時にassertはオフ
#ifndef DEBUG
#ifndef NDEBUG
#define NDEBUG
#endif
#endif

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

#define ALL(x) (x).begin(), (x).end()
template <class T> using vec = vector<T>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vec<vec<ll>> param(N, vec<ll>(5));
    vec<vec<ll>> manhattan(N, vec<ll>(1 << 4));
    vec<ll> maxManhattan(1 << 4), minManhattan(1 << 4);
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 5; j++) {
            cin >> param[i][j];
        }
    }
    for(int i = 0; i < (1 << 4); i++) {
        for(int j = 0; j < N; j++) {
            ll sum = param[j][4];
            for(int k = 0; k < 4; k++) {
                if(i & (1 << k)) {
                    sum += param[j][k];
                } else {
                    sum -= param[j][k];
                }
            }
            manhattan[j][i] = sum;
        }
    }
    for(int i = 0; i < (1 << 4); i++) {
        ll maxI = -1e+18, minI = 1e+18;
        for(int j = 0; j < N; j++) {
            maxI = max(maxI, manhattan[j][i]);
            minI = min(minI, manhattan[j][i]);
        }
        maxManhattan[i] = maxI, minManhattan[i] = minI;
    }
    for(int i = 0; i < N; i++) {
        ll ans = 0;
        for(int j = 0; j < (1 << 4); j++) {
            ans = max({ans, maxManhattan[j] - manhattan[i][j], manhattan[i][j] - minManhattan[j]});
        }
        cout << ans << "\n";
    }
}
0