結果
| 問題 | No.1360 [Zelkova 4th Tune] 協和音 |
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-01-22 21:34:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 2,000 ms |
| コード長 | 605 bytes |
| 記録 | |
| コンパイル時間 | 2,280 ms |
| コンパイル使用メモリ | 195,128 KB |
| 最終ジャッジ日時 | 2025-01-18 03:51:08 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int N;
LL dp[1<<18];
int main() {
cin>>N;
rep(i,1<<N) dp[i]=0;
rep(i,N){ int a; cin>>a; dp[1<<i]=a; }
rep(i,N) rep(j,N){ int b; cin>>b; if(i<j) dp[(1<<i)|(1<<j)]=b; }
rep(i,N) rep(j,1<<N) if(~j&(1<<i)) dp[j|(1<<i)]+=dp[j];
pair<LL,int> ans={0,0}; rep(i,1<<N) ans=max(ans,{dp[i],i});
cout<<ans.first<<endl;
vector<int> L; rep(i,N) if((ans.second>>i)&1) L.push_back(i+1);
rep(i,L.size()){ if(i) cout<<" "; cout<<L[i]; } cout<<endl;
return 0;
}
Nachia