結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー mmn15277198mmn15277198
提出日時 2021-01-26 22:35:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,013 bytes
コンパイル時間 1,613 ms
コンパイル使用メモリ 172,336 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-06 01:39:08
合計ジャッジ時間 8,936 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#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[now[x]][now[y]];
			}
		}
		
		if(cost > ans){
			ans = cost;
			swap(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;
}
0