結果
問題 | No.1360 [Zelkova 4th Tune] 協和音 |
ユーザー |
![]() |
提出日時 | 2023-09-04 01:40:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 1,295 bytes |
コンパイル時間 | 2,009 ms |
コンパイル使用メモリ | 198,916 KB |
最終ジャッジ日時 | 2025-02-16 18:31:49 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 47 |
ソースコード
#include <bits/stdc++.h>#include<iostream>#include<map>#include<vector>#include <algorithm>#include<math.h>#include <iomanip>#include<set>#include <numeric>#include<string>using namespace std;int main(){long long n, max1=-1;bitset<18> maxbit;cin >> n;vector<long long> a(n);vector<vector<long long>> b(n, vector<long long>(n));for (int i = 0; i < n; i++) cin >> a[i];for (int i = 0; i < n; i++){for (int j = 0; j < n; j++){cin >> b[i][j];}}for (int tmp = 0; tmp < (1 << 18); tmp++){bitset<18> s(tmp);long long sum1 = 0;for (int i = 0; i < n; i++){if (s.test(i)){sum1 += a[i];if (i != n-1){for (int j = i; j < n; j++){if(s.test(j)){sum1 += b[i][j];}}}}}if (tmp == 1 || sum1 > max1){max1 = sum1;maxbit = s;}}cout << max1 << "\n";string delim = "";for (int i = 0; i < 18; i++){if (maxbit.test(i)){cout << delim << i+1;delim = " ";}}cout << endl;}