結果
| 問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-22 22:53:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 2,000 ms |
| コード長 | 1,037 bytes |
| コンパイル時間 | 1,052 ms |
| コンパイル使用メモリ | 76,132 KB |
| 最終ジャッジ日時 | 2025-01-18 05:19:26 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 |
ソースコード
#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 = 1; 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;
}