結果

問題 No.2261 Coffee
ユーザー tsugutsugutsugutsugu
提出日時 2023-04-07 21:46:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 1,211 bytes
コンパイル時間 1,891 ms
コンパイル使用メモリ 169,352 KB
実行使用メモリ 32,256 KB
最終ジャッジ日時 2024-04-10 16:53:43
合計ジャッジ時間 6,649 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 5 ms
6,940 KB
testcase_18 AC 4 ms
6,944 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 4 ms
6,944 KB
testcase_21 AC 5 ms
6,944 KB
testcase_22 AC 4 ms
6,944 KB
testcase_23 AC 6 ms
6,944 KB
testcase_24 AC 129 ms
29,952 KB
testcase_25 AC 109 ms
26,240 KB
testcase_26 AC 141 ms
32,000 KB
testcase_27 AC 128 ms
29,696 KB
testcase_28 AC 73 ms
27,392 KB
testcase_29 AC 69 ms
26,880 KB
testcase_30 AC 54 ms
21,632 KB
testcase_31 AC 89 ms
32,128 KB
testcase_32 AC 90 ms
32,128 KB
testcase_33 AC 89 ms
32,256 KB
testcase_34 AC 91 ms
32,128 KB
testcase_35 AC 90 ms
32,128 KB
testcase_36 AC 91 ms
32,256 KB
testcase_37 AC 89 ms
32,128 KB
testcase_38 AC 139 ms
32,112 KB
testcase_39 AC 138 ms
32,000 KB
testcase_40 AC 138 ms
32,128 KB
testcase_41 AC 138 ms
32,256 KB
testcase_42 AC 136 ms
32,000 KB
testcase_43 AC 141 ms
32,092 KB
testcase_44 AC 136 ms
32,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<long long>> a(n, vector<long long>(32));
    vector<long long> mx(32), mi(32);
    for (int i = 0; i < n; i++) {
        vector<long long> b(5);
        for (int j = 0; j < 5; j++) {
            cin >> b[j];
        }
        for (int j = 0; j < (1 << 5); j++) {
            long long sum = 0;
            for (int k = 0; k < 5; k++) {
                if ((j >> k) & 1) {
                    sum += b[k];
                } else {
                    sum -= b[k];
                }
            }
            a[i][j] = sum;
        }
        for (int j = 0; j < (1 << 5); j++) {
            if (i == 0) {
                mx[j] = a[i][j];
                mi[j] = a[i][j];
            } else {
                mx[j] = max(mx[j], a[i][j]);
                mi[j] = min(mi[j], a[i][j]);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        long long ans = 0;
        for (int j = 0; j < (1 << 5); j++) {
            ans = max(ans, mx[j] - a[i][j]);
            ans = max(ans, a[i][j] - mi[j]);
        }
        cout << ans << '\n';
    }
}
0