結果

問題 No.2261 Coffee
ユーザー RedstoneGamer22RedstoneGamer22
提出日時 2023-04-10 22:01:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 386 ms / 2,000 ms
コード長 1,109 bytes
コンパイル時間 2,528 ms
コンパイル使用メモリ 199,748 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-04-16 00:46:05
合計ジャッジ時間 12,617 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 12 ms
5,376 KB
testcase_18 AC 13 ms
5,376 KB
testcase_19 AC 10 ms
5,376 KB
testcase_20 AC 9 ms
5,376 KB
testcase_21 AC 12 ms
5,376 KB
testcase_22 AC 9 ms
5,376 KB
testcase_23 AC 12 ms
5,376 KB
testcase_24 AC 353 ms
9,728 KB
testcase_25 AC 309 ms
8,832 KB
testcase_26 AC 382 ms
10,240 KB
testcase_27 AC 350 ms
9,728 KB
testcase_28 AC 135 ms
9,216 KB
testcase_29 AC 132 ms
9,088 KB
testcase_30 AC 105 ms
7,680 KB
testcase_31 AC 177 ms
10,368 KB
testcase_32 AC 179 ms
10,368 KB
testcase_33 AC 178 ms
10,240 KB
testcase_34 AC 177 ms
10,368 KB
testcase_35 AC 177 ms
10,368 KB
testcase_36 AC 179 ms
10,240 KB
testcase_37 AC 178 ms
10,240 KB
testcase_38 AC 383 ms
10,368 KB
testcase_39 AC 383 ms
10,240 KB
testcase_40 AC 386 ms
10,240 KB
testcase_41 AC 385 ms
10,368 KB
testcase_42 AC 384 ms
10,240 KB
testcase_43 AC 381 ms
10,240 KB
testcase_44 AC 383 ms
10,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int K = 5;

int main()
{
    int n; cin >> n;
    vector<vector<int64_t>> a(n, vector<int64_t>(K));
    for(auto &e : a) for(auto &ee : e) cin >> ee;

    vector<int64_t> maxi(1 << K, -(1LL << 60));

    for(auto &e : a) {
        for(int mask = 0; mask < (1 << K); mask++) {
            int64_t sum = 0;
            for(int i = 0; i < K; i++) {
                int sg = (((mask >> i) & 1) ? +1 : -1);
                sum += sg * e[i];
            }
            maxi[mask] = max(maxi[mask], sum);
        }
    }

    for(auto &e : a) {
        int64_t ans = -(1LL << 60);
        for(int mask = 0; mask < (1 << K); mask++) {
            int64_t sum = 0;
            for(int i = 0; i < K; i++) {
                int sg = (((mask >> i) & 1) ? +1 : -1);
                sum += sg * e[i];
            }

            int omask = ((1 << K) - 1) ^ mask;

            // cerr << bitset<K>(mask) << sum << " " << maxi[omask] << endl;

            sum += maxi[omask];
            ans = max(ans, sum);
        }

        cout << ans << '\n';
    }

    return 0;
}
0