結果
| 問題 | 
                            No.1360 [Zelkova 4th Tune] 協和音
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-01-22 22:49:22 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,001 bytes | 
| コンパイル時間 | 2,744 ms | 
| コンパイル使用メモリ | 200,132 KB | 
| 最終ジャッジ日時 | 2025-01-18 05:14:28 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 13 WA * 34 | 
ソースコード
/**
*    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[i][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;
}