結果

問題 No.2261 Coffee
ユーザー planesplanes
提出日時 2023-04-07 21:48:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 479 ms / 2,000 ms
コード長 854 bytes
コンパイル時間 1,572 ms
コンパイル使用メモリ 169,908 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-04-10 16:55:18
合計ジャッジ時間 12,312 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 15 ms
6,944 KB
testcase_18 AC 14 ms
6,944 KB
testcase_19 AC 12 ms
6,944 KB
testcase_20 AC 11 ms
6,940 KB
testcase_21 AC 14 ms
6,944 KB
testcase_22 AC 11 ms
6,944 KB
testcase_23 AC 15 ms
6,940 KB
testcase_24 AC 445 ms
9,856 KB
testcase_25 AC 382 ms
8,960 KB
testcase_26 AC 477 ms
10,240 KB
testcase_27 AC 440 ms
9,728 KB
testcase_28 AC 222 ms
9,088 KB
testcase_29 AC 217 ms
8,960 KB
testcase_30 AC 167 ms
7,680 KB
testcase_31 AC 283 ms
10,240 KB
testcase_32 AC 282 ms
10,284 KB
testcase_33 AC 283 ms
10,240 KB
testcase_34 AC 282 ms
10,496 KB
testcase_35 AC 284 ms
10,240 KB
testcase_36 AC 280 ms
10,240 KB
testcase_37 AC 284 ms
10,368 KB
testcase_38 AC 479 ms
10,240 KB
testcase_39 AC 471 ms
10,240 KB
testcase_40 AC 474 ms
10,240 KB
testcase_41 AC 466 ms
10,240 KB
testcase_42 AC 476 ms
10,240 KB
testcase_43 AC 474 ms
10,240 KB
testcase_44 AC 474 ms
10,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

  #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

int main() {
  ll N;cin>>N;
  vector<vector<ll>> vec(N,vector<ll> (5));
  for(ll i=0;i<N;i++) {
    for(ll j=0;j<5;j++) cin>>vec[i][j];
  }



vector<ll> note((1LL<<5),-1000000000000000);
for(ll i=0;i<(1LL<<5);i++) {
  for(ll j=0;j<N;j++) {
    ll count=0;
    for(ll h=0;h<5;h++) {
      if(i&(1LL<<h)) count-=vec[j][h];
      else count+=vec[j][h];
    }
   note[i]=max(note[i],count);
  }
}

for(ll i=0;i<N;i++) {
ll ans=0;
  
    for(ll j=0;j<(1LL<<5);j++) {
      ll count=0;
  for(ll h=0;h<5;h++) {
    if(j&(1LL<<h)) count-=vec[i][h];
    else count+=vec[i][h];
  }
  ll t=(1LL<<5)-1;
  t^=j;
  ans=max(ans,count+note[t]);
  

    }
    cout<<ans<<endl;
}

}

0