結果

問題 No.2261 Coffee
ユーザー mtrhmtrh
提出日時 2023-04-07 23:08:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 492 ms / 2,000 ms
コード長 1,250 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 203,048 KB
実行使用メモリ 40,192 KB
最終ジャッジ日時 2024-04-10 17:58:00
合計ジャッジ時間 12,522 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 14 ms
6,944 KB
testcase_18 AC 13 ms
5,376 KB
testcase_19 AC 12 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 14 ms
5,376 KB
testcase_22 AC 11 ms
5,376 KB
testcase_23 AC 14 ms
5,376 KB
testcase_24 AC 461 ms
37,504 KB
testcase_25 AC 372 ms
32,512 KB
testcase_26 AC 465 ms
39,936 KB
testcase_27 AC 421 ms
37,120 KB
testcase_28 AC 225 ms
33,920 KB
testcase_29 AC 219 ms
33,408 KB
testcase_30 AC 173 ms
26,752 KB
testcase_31 AC 287 ms
40,064 KB
testcase_32 AC 286 ms
40,016 KB
testcase_33 AC 285 ms
40,192 KB
testcase_34 AC 283 ms
40,076 KB
testcase_35 AC 293 ms
39,936 KB
testcase_36 AC 290 ms
40,064 KB
testcase_37 AC 294 ms
39,936 KB
testcase_38 AC 458 ms
40,064 KB
testcase_39 AC 466 ms
39,936 KB
testcase_40 AC 474 ms
40,064 KB
testcase_41 AC 476 ms
39,936 KB
testcase_42 AC 458 ms
40,008 KB
testcase_43 AC 492 ms
39,936 KB
testcase_44 AC 466 ms
40,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<ll> c(vector<ll> &p) {
    int k = p.size();
    vector<ll> res;
    for (int bit = 0; bit < (1 << k); bit++) {
        ll tmp = 0;
        for (int i = 0; i < k; i++) {
            if (bit & (1 << i)) {
                tmp += p[i];
            } else {
                tmp -= p[i];
            }
        }
        res.push_back(tmp);
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<vector<ll>> param(N, vector<ll>(5));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 5; j++) {
            cin >> param[i][j];
        }
    }
    ll inf = 1LL << 60;
    vector<ll> m(32, inf), M(32, -inf);
    vector<vector<ll>> chs(N);
    for (int i = 0; i < N; i++) {
        auto ch = c(param[i]);
        chs[i] = ch;
        for (int j = 0; j < 32; j++) {
            m[j] = min(m[j], ch[j]);
            M[j] = max(M[j], ch[j]);
        }
    }
    vector<ll> ans(N);
    for (int k = 0; k < N; k++) {
        for (int j = 0; j < 32; j++) {
            ans[k] =
                max({ans[k], abs(chs[k][j] - m[j]), abs(chs[k][j] - M[j])});
        }
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}
0