結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー Noboru2020Noboru2020
提出日時 2021-01-22 21:41:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 943 bytes
コンパイル時間 2,492 ms
コンパイル使用メモリ 192,812 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 18:12:10
合計ジャッジ時間 10,489 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 10 ms
4,376 KB
testcase_24 AC 19 ms
4,376 KB
testcase_25 AC 76 ms
4,380 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 76 ms
4,380 KB
testcase_29 AC 6 ms
4,376 KB
testcase_30 AC 10 ms
4,376 KB
testcase_31 AC 10 ms
4,376 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 AC 76 ms
4,376 KB
testcase_34 AC 76 ms
4,380 KB
testcase_35 AC 76 ms
4,376 KB
testcase_36 AC 77 ms
4,376 KB
testcase_37 AC 76 ms
4,380 KB
testcase_38 AC 76 ms
4,376 KB
testcase_39 AC 76 ms
4,376 KB
testcase_40 AC 76 ms
4,376 KB
testcase_41 AC 76 ms
4,380 KB
testcase_42 AC 76 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N;cin>>N;
  vector<int>a(N);
  for(int i=0; i<N; i++){
    cin>>a[i];
  }
  vector<vector<int>>vec(N,vector<int>(N));
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      cin>>vec[i][j];
    }
  }
  vector<int>ans;
  int sum=0;
  for(int i=1; i<(1<<N); i++){
    int cnt=0;
    vector<int>memo;
    for(int j=0; j<N; j++){
      if(i&(1<<j)){
        cnt+=a[j];
        memo.push_back(j+1);
      }
    }
    int y=memo.size();
    for(int j=0; j<y; j++){ 
      for(int k=j+1; k<y; k++){
        cnt+=vec[memo[j]-1][memo[k]-1];
      }
    }
    if(cnt>sum||i==0){
      sum=cnt;
      ans=memo;
    }
  }
  int X=ans.size();
  cout<<sum<<endl;
  for(int i=0; i<X-1; i++){
    cout<<ans[i]<<" ";
  }
  cout<<ans[X-1]<<endl;
}
0