結果
| 問題 |
No.1360 [Zelkova 4th Tune] 協和音
|
| コンテスト | |
| ユーザー |
mmn15277198
|
| 提出日時 | 2021-01-26 21:34:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,038 bytes |
| コンパイル時間 | 1,663 ms |
| コンパイル使用メモリ | 173,904 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 19:45:25 |
| 合計ジャッジ時間 | 6,796 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 37 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ld pi = 3.14159265358979;
const int mod = 1000000007;
int main(){
int n;
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++){
cin >> a[i];
}
vector<vector<int>> b(n , vector<int>(n));
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cin >> b[i][j];
}
}
int ans = 0;
vector<int>ans_bit;
for(int i = 0; i < (1 << n); i++){
int cost = 0;
vector<int> now;
for(int j = 0; j < n; j++){
if(i & (1 << j)){
cost += a[j];
now.push_back(j);
//cout << 1 << " ";
}else{
//cout << 0 << " ";
}
}
if(now.size() >= 2){
for(int x = 0; x < now.size() - 1; x++){
for(int y = x + 1; 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()){
cout << " ";
}else{
cout << endl;
}
}
return 0;
}
mmn15277198