結果

問題 No.2261 Coffee
ユーザー 👑 nu50218nu50218
提出日時 2023-04-07 21:47:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 1,549 bytes
コンパイル時間 3,548 ms
コンパイル使用メモリ 224,416 KB
実行使用メモリ 11,108 KB
最終ジャッジ日時 2024-04-27 04:36:03
合計ジャッジ時間 12,331 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,948 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 12 ms
6,940 KB
testcase_18 AC 11 ms
6,944 KB
testcase_19 AC 10 ms
6,944 KB
testcase_20 AC 8 ms
6,940 KB
testcase_21 AC 11 ms
6,944 KB
testcase_22 AC 9 ms
6,940 KB
testcase_23 AC 12 ms
6,944 KB
testcase_24 AC 335 ms
10,496 KB
testcase_25 AC 280 ms
9,344 KB
testcase_26 AC 359 ms
11,008 KB
testcase_27 AC 331 ms
10,240 KB
testcase_28 AC 267 ms
9,728 KB
testcase_29 AC 253 ms
9,600 KB
testcase_30 AC 205 ms
8,192 KB
testcase_31 AC 329 ms
11,008 KB
testcase_32 AC 317 ms
11,036 KB
testcase_33 AC 318 ms
11,008 KB
testcase_34 AC 320 ms
11,008 KB
testcase_35 AC 310 ms
11,108 KB
testcase_36 AC 322 ms
11,008 KB
testcase_37 AC 315 ms
11,008 KB
testcase_38 AC 357 ms
11,008 KB
testcase_39 AC 347 ms
11,008 KB
testcase_40 AC 347 ms
10,880 KB
testcase_41 AC 345 ms
10,880 KB
testcase_42 AC 354 ms
11,008 KB
testcase_43 AC 347 ms
11,008 KB
testcase_44 AC 347 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef LOCAL
#include <local.hpp>
#else
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2")
#include <bits/stdc++.h>
#define debug(...) ((void)0)
#define postprocess(...) ((void)0)
#endif

using namespace std;
using ll = long long;
using ld = long double;

void solve([[maybe_unused]] int test) {
    int N;
    cin >> N;

    vector<vector<ll>> v(N, vector<ll>(5, 0));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 5; j++) {
            cin >> v[i][j];
        }
    }

    vector<ll> ans(N, 0);

    for (int bits = 0; bits < (1 << 5); bits++) {
        bool positive[5];

        for (int i = 0; i < 5; i++) {
            positive[i] = bits & (1 << i);
        }

        auto opt = *max_element(v.begin(), v.end(), [&](vector<ll> a, vector<ll> b) {
            ll val_a = 0, val_b = 0;

            for (int i = 0; i < 5; i++) {
                ll k = positive[i] ? 1 : -1;

                val_a += k * a[i];
                val_b += k * b[i];
            }

            return val_a < val_b;
        });

        for (int i = 0; i < N; i++) {
            ll dist = 0;

            for (int j = 0; j < 5; j++) {
                dist += abs(v[i][j] - opt[j]);
            }

            ans[i] = max(ans[i], dist);
        }
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }

    postprocess();
}
0