結果
| 問題 | 
                            No.1360 [Zelkova 4th Tune] 協和音
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-01-22 22:51:49 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,037 bytes | 
| コンパイル時間 | 898 ms | 
| コンパイル使用メモリ | 76,392 KB | 
| 最終ジャッジ日時 | 2025-01-18 05:17:42 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 44 WA * 3 | 
ソースコード
#line 1 "main.cpp"
#include <iostream>
#include <vector>
using namespace std;
using lint = long long;
void solve() {
    int n;
    cin >> n;
    vector<lint> xs(n);
    for (auto& x : xs) cin >> x;
    auto yss = vector(n, vector(n, 0LL));
    for (auto& ys : yss) {
        for (auto& y : ys) cin >> y;
    }
    lint ma = -1;
    int mb = 0;
    for (int b = 0; b < (1 << n); ++b) {
        lint s = 0;
        for (int i = 0; i < n; ++i) {
            if ((b >> i) & 1) s += xs[i];
        }
        for (int i = 0; i < n; ++i) {
            if ((~b >> i) & 1) continue;
            for (int j = 0; j < i; ++j) {
                if ((~b >> j) & 1) continue;
                s += yss[i][j];
            }
        }
        if (s > ma) {
            ma = s;
            mb = b;
        }
    }
    cout << ma << "\n";
    for (int i = 0; i < n; ++i) {
        if ((mb >> i) & 1) cout << i + 1 << " ";
    }
    cout << "\n";
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}