結果

問題 No.2261 Coffee
ユーザー rogi52rogi52
提出日時 2023-04-07 22:45:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,113 ms / 2,000 ms
コード長 1,272 bytes
コンパイル時間 2,273 ms
コンパイル使用メモリ 205,420 KB
実行使用メモリ 10,840 KB
最終ジャッジ日時 2024-04-10 17:41:02
合計ジャッジ時間 24,072 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 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,940 KB
testcase_17 AC 17 ms
6,944 KB
testcase_18 AC 16 ms
6,940 KB
testcase_19 AC 14 ms
6,944 KB
testcase_20 AC 12 ms
6,940 KB
testcase_21 AC 17 ms
6,940 KB
testcase_22 AC 14 ms
6,940 KB
testcase_23 AC 18 ms
6,940 KB
testcase_24 AC 994 ms
10,148 KB
testcase_25 AC 810 ms
9,152 KB
testcase_26 AC 1,073 ms
10,656 KB
testcase_27 AC 982 ms
10,112 KB
testcase_28 AC 620 ms
9,472 KB
testcase_29 AC 607 ms
9,428 KB
testcase_30 AC 453 ms
8,048 KB
testcase_31 AC 836 ms
10,712 KB
testcase_32 AC 834 ms
10,784 KB
testcase_33 AC 823 ms
10,840 KB
testcase_34 AC 830 ms
10,712 KB
testcase_35 AC 822 ms
10,712 KB
testcase_36 AC 837 ms
10,712 KB
testcase_37 AC 840 ms
10,836 KB
testcase_38 AC 1,113 ms
10,708 KB
testcase_39 AC 1,109 ms
10,716 KB
testcase_40 AC 1,103 ms
10,712 KB
testcase_41 AC 1,091 ms
10,712 KB
testcase_42 AC 1,097 ms
10,644 KB
testcase_43 AC 1,095 ms
10,712 KB
testcase_44 AC 1,112 ms
10,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull  = unsigned long long;
template < class T > bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
template < class T > bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N; cin >> N;
    vector<vector<ll>> A(N, vector<ll>(5));
    rep(i,N)rep(j,5) cin >> A[i][j];
    vector<int> I;
    rep(S,1<<5) {
        vector<ll> sgn(5);
        rep(j,5) sgn[j] = (S & (1 << j) ? +1 : -1);
        vector<int> J(N);
        iota(J.begin(), J.end(), 0);
        sort(J.begin(), J.end(), [&](int L, int R) {
            ll sumL = 0, sumR = 0;
            rep(j,5) {
                sumL += sgn[j] * A[L][j];
                sumR += sgn[j] * A[R][j];
            }
            return sumL < sumR;
        });
        I.push_back(J[0]);
        I.push_back(J[N - 1]);
    }

    rep(k,N) {
        ll ans = 0;
        for(int i : I) if(i != k) {
            ll sum = 0;
            rep(j,5) sum += abs(A[k][j] - A[i][j]);
            chmax(ans, sum);
        }
        cout << ans << "\n";
    }
}
0