結果
| 問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-22 22:55:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 67 ms / 2,000 ms |
| コード長 | 1,011 bytes |
| コンパイル時間 | 2,148 ms |
| コンパイル使用メモリ | 202,160 KB |
| 最終ジャッジ日時 | 2025-01-18 05:24:58 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 |
ソースコード
/**
* author: shu8Cream
* created: 22.01.2021 22:34:57
**/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<ll> a(n);
rep(i,n) cin >> a[i];
vector<vector<ll>> b(n, vector<ll>(n));
rep(i,n)rep(j,n) cin >> b[i][j];
ll ans = 0;
vi ans2;
rep(s,1<<n){
ll cnt = 0;
vi tmp;
rep(i,n){
if(s>>i&1){
cnt+=a[i];
tmp.push_back(i);
}
}
rep(i,tmp.size()){
for(int j=i+1; j<tmp.size(); j++) cnt+=b[tmp[i]][tmp[j]];
}
ans=max(ans,cnt);
if(cnt==ans) ans2=tmp;
}
cout << ans << endl;
cout << ans2[0]+1;
rep(i,ans2.size()-1) cout << " " << ans2[i+1]+1;
cout << endl;
}