結果

問題 No.2261 Coffee
ユーザー hiro71687khiro71687k
提出日時 2023-04-07 22:12:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 754 ms / 2,000 ms
コード長 1,520 bytes
コンパイル時間 4,414 ms
コンパイル使用メモリ 259,196 KB
実行使用メモリ 40,240 KB
最終ジャッジ日時 2024-04-10 17:14:36
合計ジャッジ時間 20,095 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 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 3 ms
6,944 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 21 ms
6,940 KB
testcase_18 AC 20 ms
6,944 KB
testcase_19 AC 18 ms
6,940 KB
testcase_20 AC 15 ms
6,940 KB
testcase_21 AC 20 ms
6,940 KB
testcase_22 AC 16 ms
6,940 KB
testcase_23 AC 21 ms
6,940 KB
testcase_24 AC 689 ms
37,536 KB
testcase_25 AC 590 ms
32,880 KB
testcase_26 AC 736 ms
39,628 KB
testcase_27 AC 715 ms
37,000 KB
testcase_28 AC 375 ms
34,088 KB
testcase_29 AC 369 ms
33,500 KB
testcase_30 AC 280 ms
27,304 KB
testcase_31 AC 472 ms
39,988 KB
testcase_32 AC 473 ms
40,116 KB
testcase_33 AC 485 ms
40,108 KB
testcase_34 AC 489 ms
40,112 KB
testcase_35 AC 474 ms
40,108 KB
testcase_36 AC 487 ms
40,112 KB
testcase_37 AC 484 ms
39,984 KB
testcase_38 AC 754 ms
40,240 KB
testcase_39 AC 740 ms
40,112 KB
testcase_40 AC 735 ms
40,112 KB
testcase_41 AC 753 ms
39,996 KB
testcase_42 AC 729 ms
39,980 KB
testcase_43 AC 735 ms
39,988 KB
testcase_44 AC 736 ms
39,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=144494;
ll mod=1000000007;
int main(){
    ll n;
    cin >> n;
    vector<ll>a(n),b(n),c(n),d(n),e(n);
    vector<vector<ll>>t(n,vector<ll>(5));
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j < 5; j++)
        {
            cin >> t[i][j];
        }
    }
    vector<vector<ll>>p(32);
    vector<ll>two(30,1);
    for (ll i = 0; i < 11; i++)
    {
        two[i+1]=two[i]*2;
    }
    
    for (ll i = 0; i < n; i++)
    {
        for (ll j = 0; j < 32; j++)
        {
            ll x=0;
            for (ll k = 0; k < 5; k++)
            {
                if (j&two[k])
                {
                    x+=t[i][k];
                }else{
                    x-=t[i][k];
                }
            }
            p[j].push_back(x);
        }
    }
    for (ll i = 0; i < 32; i++)
    {
        sort(p[i].begin(),p[i].end());
    }
    for (ll i = 0; i < n; i++)
    {
        ll ans=0;
        for (ll j = 0; j < 32; j++)
        {
            ll x=0;
            for (ll k = 0; k < 5; k++)
            {
                if (j&two[k])
                {
                    x+=t[i][k];
                }else{
                    x-=t[i][k];
                }
            }
            ll y=abs(x-p[j][0]);
            y=max(y,abs(x-p[j][p[j].size()-1]));
            ans=max(ans,y);
        }
        cout << ans << endl;
    }
}
0