結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー kyo1kyo1
提出日時 2021-01-24 11:15:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,026 bytes
コンパイル時間 2,337 ms
コンパイル使用メモリ 206,144 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-30 19:15:13
合計ジャッジ時間 10,504 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 7 ms
4,380 KB
testcase_24 AC 13 ms
4,376 KB
testcase_25 AC 54 ms
4,384 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 54 ms
4,380 KB
testcase_29 AC 4 ms
4,380 KB
testcase_30 AC 7 ms
4,380 KB
testcase_31 AC 7 ms
4,380 KB
testcase_32 AC 3 ms
4,376 KB
testcase_33 AC 54 ms
4,380 KB
testcase_34 AC 54 ms
4,376 KB
testcase_35 AC 54 ms
4,380 KB
testcase_36 AC 54 ms
4,380 KB
testcase_37 AC 54 ms
4,376 KB
testcase_38 AC 53 ms
4,380 KB
testcase_39 AC 54 ms
4,380 KB
testcase_40 AC 54 ms
4,376 KB
testcase_41 AC 53 ms
4,380 KB
testcase_42 AC 53 ms
4,380 KB
testcase_43 AC 2 ms
4,380 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

template <typename T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (auto &&e : A) {
    cin >> e;
  }
  vector<vector<int64_t>> B(N, vector<int64_t>(N));
  for (auto &&e : B) {
    for (auto &&f : e) {
      cin >> f;
    }
  }
  pair<int, int64_t> res = make_pair(0, 0);
  for (int b = 0; b < (1 << N); b++) {
    int64_t r = 0;
    for (int i = 0; i < N; i++) {
      if ((b >> i) & 1) {
        r += A[i];
        for (int j = i + 1; j < N; j++) {
          if ((b >> j) & 1) r += B[i][j];
        }
      }
    }
    if (chmax(res.second, r)) {
      res.first = b;
    }
  }
  cout << res.second << '\n';
  vector<int> J;
  for (int i = 0; i < N; i++) {
    if ((res.first >> i) & 1) J.emplace_back(i);
  }
  for (const auto &e : J) {
    cout << e + 1 << (&e == &J.back() ? '\n' : ' ');
  }
  return 0;
}
0