結果
| 問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2021-01-22 21:31:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 1,394 bytes |
| コンパイル時間 | 1,069 ms |
| コンパイル使用メモリ | 94,440 KB |
| 最終ジャッジ日時 | 2025-01-18 03:47:50 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int n; cin >> n;
vector<ll> a(n);
vector<vector<ll>> b(n, vector<ll>(n));
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cin >> b[i][j];
}
}
ll ans = -1e15;
int s = 0;
for(int i = 1; i < (1<<n); i++){
ll tmp = 0;
for(int j = 0; j < n; j++){
if(i&(1<<j)){
tmp += a[j];
for(int k = j+1; k < n; k++){
if(i&(1<<k)) tmp += b[j][k];
}
}
}
if(chmax(ans, tmp)) s = i;
}
cout << ans << endl;
for(int i = 0; i < n; i++){
if(s&(1<<i)) cout << i+1 << ' ';
}
cout << endl;
}
milanis48663220