結果

問題 No.2261 Coffee
ユーザー t98slidert98slider
提出日時 2023-04-07 22:04:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 694 ms / 2,000 ms
コード長 1,562 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 176,312 KB
実行使用メモリ 11,184 KB
最終ジャッジ日時 2024-04-10 17:07:06
合計ジャッジ時間 16,426 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 16 ms
6,944 KB
testcase_18 AC 15 ms
6,944 KB
testcase_19 AC 14 ms
6,940 KB
testcase_20 AC 12 ms
6,944 KB
testcase_21 AC 16 ms
6,944 KB
testcase_22 AC 12 ms
6,940 KB
testcase_23 AC 16 ms
6,940 KB
testcase_24 AC 643 ms
10,468 KB
testcase_25 AC 549 ms
9,472 KB
testcase_26 AC 694 ms
11,020 KB
testcase_27 AC 618 ms
10,308 KB
testcase_28 AC 364 ms
9,776 KB
testcase_29 AC 352 ms
9,684 KB
testcase_30 AC 277 ms
8,092 KB
testcase_31 AC 462 ms
10,928 KB
testcase_32 AC 472 ms
10,952 KB
testcase_33 AC 467 ms
11,112 KB
testcase_34 AC 458 ms
11,184 KB
testcase_35 AC 470 ms
10,932 KB
testcase_36 AC 456 ms
10,944 KB
testcase_37 AC 463 ms
10,936 KB
testcase_38 AC 670 ms
11,060 KB
testcase_39 AC 658 ms
10,928 KB
testcase_40 AC 674 ms
10,964 KB
testcase_41 AC 667 ms
10,932 KB
testcase_42 AC 653 ms
11,060 KB
testcase_43 AC 658 ms
11,060 KB
testcase_44 AC 661 ms
11,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<array<ll, 5>> a(N);
    vector<ll> ans(N, -(1ll << 60));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 5; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < 32; i++){
        vector<pair<ll,ll>> b(N);
        for(int j = 0; j < N; j++){
            ll x = 0, y = 0;
            for(int k = 0; k < 5; k++){
                if(i >> k & 1) x += a[j][k];
                else y += a[j][k];
            }
            b[j] = make_pair(x, y);
        }
        auto c = b;
        sort(c.begin(), c.end(), [&](pair<ll,ll> lhs, pair<ll,ll> rhs){
            return lhs.first + lhs.second < rhs.first + rhs.second;
        });
        ll mn = c[0].first + c[0].second, mx = c[N - 1].first + c[N - 1].second;
        for(int j = 0; j < N; j++){
            ll v = b[j].first + b[j].second;
            ans[j] = max(ans[j], abs(mn - v));
            ans[j] = max(ans[j], abs(mx - v));
        }
        sort(c.begin(), c.end(), [&](pair<ll,ll> lhs, pair<ll,ll> rhs){
            return lhs.first - lhs.second < rhs.first - rhs.second;
        });
        mn = c[0].first - c[0].second, mx = c[N - 1].first - c[N - 1].second;
        for(int j = 0; j < N; j++){
            ll v = b[j].first - b[j].second;
            ans[j] = max(ans[j], abs(mn - v));
            ans[j] = max(ans[j], abs(mx - v));
        }
    }
    for(int i = 0; i < N; i++) cout << ans[i] << '\n';
}
0