結果
問題 | No.1360 [Zelkova 4th Tune] 協和音 |
ユーザー |
![]() |
提出日時 | 2021-01-26 22:29:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 998 bytes |
コンパイル時間 | 1,639 ms |
コンパイル使用メモリ | 176,348 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 20:39:13 |
合計ジャッジ時間 | 6,082 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const ld pi = 3.14159265358979; const int mod = 1000000007; const ll inf = 123456789123456; int main(){ int n; cin >> n; vector<ll> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; } vector<vector<ll>> b(n , vector<ll>(n , 0)); for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ cin >> b[i][j]; } } ll ans = -inf; vector<int>ans_bit; for(int i = 0; i < (1 << n); i++){ ll cost = 0; vector<int> now; for(int j = 0; j < n; j++){ if(i & (1 << j)){ cost += a[j]; now.push_back(j); } } //cout << bitset<20>(i) << endl; for(int x = 0; x < now.size(); x++){ for(int y = x; y < now.size(); y++){ cost += b[x][y]; } } if(cost >= ans){ ans = cost; ans_bit = now; } } cout << ans << endl; for(int i = 0; i < ans_bit.size(); i++){ cout << ans_bit[i] + 1; if(i != ans_bit.size() - 1)cout << " "; else cout << endl; } return 0; }