結果
問題 | No.1360 [Zelkova 4th Tune] 協和音 |
ユーザー |
![]() |
提出日時 | 2024-10-28 00:34:02 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 177 ms / 2,000 ms |
コード長 | 821 bytes |
コンパイル時間 | 3,085 ms |
コンパイル使用メモリ | 251,740 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-28 00:34:12 |
合計ジャッジ時間 | 9,601 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 47 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef LOCAL#include "settings/debug.cpp"#else#define Debug(...) void(0)#endif#define rep(i, n) for (int i = 0; i < (n); ++i)using ll = long long;using ull = unsigned long long;int main() {int n;cin >> n;vector<ll> a(n);rep(i, n) cin >> a[i];vector b(n, vector<ll>(n));rep(i, n) rep(j, n) cin >> b[i][j];pair<ll, int> ans = { -1e18, 0 };rep(bit, 1 << n) {if (bit == 0) continue;ll sum = 0;rep(i, n) {if (bit & (1 << i)) sum += 2 * a[i];}rep(i, n) rep(j, n) {if ((bit & (1 << i)) && (bit & (1 << j))) sum += b[i][j];}if (sum / 2 > ans.first) ans = { sum / 2, bit };}cout << ans.first << endl;rep(i, n) if (ans.second & (1 << i)) cout << i + 1 << ' ';cout << endl;return 0;}