結果
| 問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-22 21:41:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 101 ms / 2,000 ms |
| コード長 | 1,058 bytes |
| コンパイル時間 | 2,213 ms |
| コンパイル使用メモリ | 171,732 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 22:59:50 |
| 合計ジャッジ時間 | 6,813 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y));
#define chmax(x,y) x = max((x),(y));
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e17;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;
int main(){
ll n;
cin >> n;
vector<ll> a(n);
vector<vector<ll>> b(n,vector<ll>(n,0));
rep(i,n) cin >> a[i];
rep(i,n)rep(j,n) cin >> b[i][j];
ll ans = -LINF;
ll g = 0;
for(ll bit=1;bit<(1LL<<n);bit++){
ll res = 0;
rep(i,n){
if(bit>>i&1LL){
res += a[i];
rep(j,i){
if(bit>>j&1LL) res += b[i][j];
}
}
}
if(res > ans){
ans = res;
g = bit;
}
}
cout << ans << endl;
rep(i,n){
if(g>>i&1LL) cout << (i+1) << " ";
}
cout << endl;
return 0;
}