結果

問題 No.2261 Coffee
ユーザー twooimp2twooimp2
提出日時 2024-02-23 16:59:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 6,634 ms
コンパイル使用メモリ 305,616 KB
実行使用メモリ 12,004 KB
最終ジャッジ日時 2024-02-23 16:59:40
合計ジャッジ時間 16,915 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 8 ms
6,676 KB
testcase_18 AC 8 ms
6,676 KB
testcase_19 AC 7 ms
6,676 KB
testcase_20 AC 9 ms
6,676 KB
testcase_21 AC 8 ms
6,676 KB
testcase_22 AC 6 ms
6,676 KB
testcase_23 AC 8 ms
6,676 KB
testcase_24 AC 219 ms
11,392 KB
testcase_25 AC 179 ms
10,240 KB
testcase_26 AC 221 ms
11,944 KB
testcase_27 AC 205 ms
11,264 KB
testcase_28 AC 149 ms
10,592 KB
testcase_29 AC 150 ms
10,368 KB
testcase_30 AC 114 ms
8,832 KB
testcase_31 AC 180 ms
12,004 KB
testcase_32 AC 184 ms
12,004 KB
testcase_33 AC 182 ms
12,004 KB
testcase_34 AC 181 ms
12,004 KB
testcase_35 AC 184 ms
12,004 KB
testcase_36 AC 186 ms
12,004 KB
testcase_37 AC 178 ms
12,004 KB
testcase_38 AC 223 ms
12,004 KB
testcase_39 AC 222 ms
12,004 KB
testcase_40 AC 226 ms
12,004 KB
testcase_41 AC 223 ms
12,004 KB
testcase_42 AC 225 ms
12,004 KB
testcase_43 AC 223 ms
12,004 KB
testcase_44 AC 221 ms
12,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//https://naoyat.hatenablog.jp/entry/k-dimension-manhattan-distance
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;

void IO(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

int main(){
  IO();
  ll n;
  cin>>n;
  vector<vector<ll>> info(n,vector<ll>(5));
  for(ll i=0;i<n;i++){
    for(ll j=0;j<5;j++){
      cin>>info[i][j];
    }
  }
  vector<ll> ans(n);
  for(ll b=0;b<(1<<4);b++){
    ll mx=-1e18;
    ll mn=1e18;
    vector<ll> v(n);
    for(ll i=0;i<n;i++){
      for(ll j=0;j<5;j++){
        if(b&(1<<j)){
          v[i]+=info[i][j];
        }else{
          v[i]-=info[i][j];
        }
      }
      mx=max(mx,v[i]);
      mn=min(mn,v[i]);
    }
    for(ll i=0;i<n;i++){
      ans[i]=max({ans[i],v[i]-mn,mx-v[i]});
    }
  }
  for(ll i=0;i<n;i++){
    cout<<ans[i]<<endl;
  }
}
0