結果

問題 No.2261 Coffee
ユーザー wanuiwanui
提出日時 2023-04-07 22:30:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 2,427 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 201,860 KB
実行使用メモリ 7,292 KB
最終ジャッジ日時 2024-04-10 17:28:49
合計ジャッジ時間 7,363 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 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,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 5 ms
6,940 KB
testcase_18 AC 5 ms
6,940 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 4 ms
6,940 KB
testcase_21 AC 5 ms
6,944 KB
testcase_22 AC 4 ms
6,940 KB
testcase_23 AC 5 ms
6,940 KB
testcase_24 AC 113 ms
6,944 KB
testcase_25 AC 98 ms
6,944 KB
testcase_26 AC 119 ms
7,216 KB
testcase_27 AC 113 ms
6,940 KB
testcase_28 AC 54 ms
6,944 KB
testcase_29 AC 52 ms
6,940 KB
testcase_30 AC 43 ms
6,944 KB
testcase_31 AC 70 ms
7,208 KB
testcase_32 AC 69 ms
7,168 KB
testcase_33 AC 70 ms
7,136 KB
testcase_34 AC 72 ms
7,168 KB
testcase_35 AC 70 ms
7,248 KB
testcase_36 AC 68 ms
7,244 KB
testcase_37 AC 71 ms
7,252 KB
testcase_38 AC 124 ms
7,292 KB
testcase_39 AC 122 ms
7,128 KB
testcase_40 AC 125 ms
7,108 KB
testcase_41 AC 124 ms
7,100 KB
testcase_42 AC 126 ms
7,168 KB
testcase_43 AC 122 ms
7,220 KB
testcase_44 AC 123 ms
7,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}
void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);}
void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}
void ioinit() { cout<<fixed<<setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); }
#define debug1(a) { cerr<<#a<<":"<<a<<endl; }
#define debug2(a,b) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl; }
#define debug3(a,b,c) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl; }
#define debug4(a,b,c,d) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl; }
// clang-format on
struct coffee {
    ll a;
    ll b;
    ll c;
    ll d;
    ll e;
};
int main() {
    ioinit();
    vector<ll> maxs;
    ll N;
    cin >> N;
    vector<coffee> cofs(N);
    for (ll i = 0; i < N; i++) {
        coffee c;
        cin >> c.a >> c.b >> c.c >> c.d >> c.e;
        cofs[i] = c;
    }
    for (ll bin = 0; bin < 32; bin++) {
        coffee base;
        for (ll j = 0; j < 5; j++) {
            ll x = 0;
            if ((bin >> j) & 1) {
                x = 1001001001001001;
            }
            if (j == 0) base.a = x;
            if (j == 1) base.b = x;
            if (j == 2) base.c = x;
            if (j == 3) base.d = x;
            if (j == 4) base.e = x;
        }
        pll mx = {-1, -1};
        for (ll i = 0; i < N; i++) {
            coffee c = cofs[i];
            ll diff = abs(base.a - c.a) + abs(base.b - c.b) + abs(base.c - c.c) + abs(base.d - c.d) + abs(base.e - c.e);
            pll cur = {diff, i};
            mx = max(cur, mx);
        }
        maxs.push_back(mx.second);
    }
    for (ll i = 0; i < N; i++) {
        ll ans = 0;
        for (auto j : maxs) {
            coffee c = cofs[i];
            coffee d = cofs[j];
            ll diff = abs(d.a - c.a) + abs(d.b - c.b) + abs(d.c - c.c) + abs(d.d - c.d) + abs(d.e - c.e);
            ans = max(diff, ans);
        }
        print(ans);
    }
    return 0;
}
0