結果
| 問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-22 21:32:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 742 bytes |
| コンパイル時間 | 2,021 ms |
| コンパイル使用メモリ | 205,780 KB |
| 最終ジャッジ日時 | 2025-01-18 03:48:50 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 34 |
ソースコード
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using ll = long long;
int main(){
int n;
cin >> n;
vector<ll> a(n);
vector<vector<ll>> b(n,vector<ll>(n));
for(auto &i:a)cin >> i;
for(auto &i:b)for(auto &j:i)cin >> j;
vector<int> ansvec = {0};
ll ans = a[0];
for(int bit=0;bit<(1<<n);bit++){
ll now = 0;
set<int> st;
for(int j = 0;j<n;j++){
if(bit>>j&1){
st.insert(j);
now += a[j];
}
}
vector<int> st2;
for(auto &i:st)st2.push_back(i);
for(int i = 0;i<st2.size();i++){
for(int j = i+1;j<st2.size();j++){
now += b[i][j];
}
}
if(now>ans){
ans = now;
ansvec = st2;
}
}
cout<<ans<<endl;
for(auto &i:ansvec)cout<<i+1<<' ' ;cout<<endl;
}