結果
問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
ユーザー |
|
提出日時 | 2021-01-22 21:49:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,008 bytes |
コンパイル時間 | 4,235 ms |
コンパイル使用メモリ | 197,576 KB |
最終ジャッジ日時 | 2025-01-18 04:10:14 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 44 WA * 3 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; long long ans = -(1LL << 60); vector<int> a(n); for (auto& x : a) cin >> x; vector<vector<int>> b(n, vector<int>(n)); for (auto& v : b) for (auto& x : v) cin >> x; vector<int> ans_sounds; for (int mask = 0; mask < (1 << n); mask++) { long long cur = 0; for (int i = 0; i < n; i++) if ((mask >> i) & 1) cur += a[i]; long long bonus = 0; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { if ((mask >> i) & 1 && (mask >> j) & 1) bonus += b[i][j]; } bonus >>= 1; cur += bonus; if (cur > ans) { ans = cur; ans_sounds.clear(); for (int i = 0; i < n; i++) if ((mask >> i) & 1) ans_sounds.emplace_back(i + 1); } } cout << ans << endl; for (int i = 0; i < (int) ans_sounds.size(); i++) { if (i > 0) cout << " "; cout << ans_sounds[i]; } cout << endl; return 0; }