結果

問題 No.1360 [Zelkova 4th Tune] 協和音
ユーザー 小野寺健小野寺健
提出日時 2021-05-21 14:24:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,175 bytes
コンパイル時間 3,917 ms
コンパイル使用メモリ 78,076 KB
実行使用メモリ 47,968 KB
最終ジャッジ日時 2024-04-18 14:16:41
合計ジャッジ時間 18,085 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,308 KB
testcase_01 AC 137 ms
41,264 KB
testcase_02 AC 120 ms
40,316 KB
testcase_03 AC 114 ms
40,004 KB
testcase_04 AC 114 ms
40,076 KB
testcase_05 AC 131 ms
41,284 KB
testcase_06 AC 132 ms
41,464 KB
testcase_07 AC 132 ms
41,300 KB
testcase_08 AC 129 ms
41,260 KB
testcase_09 AC 128 ms
41,056 KB
testcase_10 AC 134 ms
41,384 KB
testcase_11 AC 137 ms
41,448 KB
testcase_12 AC 118 ms
40,272 KB
testcase_13 AC 121 ms
40,004 KB
testcase_14 AC 139 ms
41,376 KB
testcase_15 AC 141 ms
41,664 KB
testcase_16 AC 135 ms
41,260 KB
testcase_17 AC 141 ms
41,644 KB
testcase_18 AC 134 ms
41,452 KB
testcase_19 AC 143 ms
41,832 KB
testcase_20 AC 135 ms
41,660 KB
testcase_21 AC 136 ms
41,548 KB
testcase_22 AC 145 ms
41,780 KB
testcase_23 AC 275 ms
47,160 KB
testcase_24 AC 320 ms
47,060 KB
testcase_25 AC 436 ms
47,968 KB
testcase_26 AC 188 ms
43,804 KB
testcase_27 AC 154 ms
42,224 KB
testcase_28 AC 418 ms
47,128 KB
testcase_29 AC 235 ms
46,824 KB
testcase_30 AC 255 ms
46,736 KB
testcase_31 AC 256 ms
47,204 KB
testcase_32 AC 191 ms
44,920 KB
testcase_33 AC 380 ms
47,264 KB
testcase_34 AC 381 ms
47,284 KB
testcase_35 AC 430 ms
47,176 KB
testcase_36 AC 407 ms
47,008 KB
testcase_37 AC 422 ms
47,688 KB
testcase_38 AC 390 ms
47,388 KB
testcase_39 AC 369 ms
47,232 KB
testcase_40 AC 365 ms
47,452 KB
testcase_41 AC 383 ms
47,172 KB
testcase_42 AC 358 ms
47,268 KB
testcase_43 AC 132 ms
41,260 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class No1360 {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		List<Integer> A = new ArrayList<Integer>();
		for (int i=0; i < N; i++) {
			A.add(scan.nextInt());
		}
		List<List<Integer>> B = new ArrayList<List<Integer>>();
		for (int i=0; i < N; i++) {
			List<Integer> l = new ArrayList<Integer>();
			for (int j=0; j < N; j++) {
				l.add(scan.nextInt());
			}
			B.add(l);
		}
		scan.close();
		long Max = Long.MIN_VALUE;
		int Max_comb = -1;
		for (int i=0; i < 1 << N; i++) {
			long point = 0;
			List<Integer> prev = new ArrayList<Integer>();
			for (int j=0; j < N; j++) {
				if ((i & (1 << j)) != 0) {
					point += A.get(j);
					for (int p : prev) {
						point += B.get(p).get(j);
					}
					prev.add(j);
				}
			}
			if (Max < point) {
				Max = point;
				Max_comb = i;
			}
		}
		List<String> J = new ArrayList<String>();
		for (int j=0; j < N; j++) {
			if ((Max_comb & (1 << j)) != 0) {
				J.add(String.valueOf(j+1));
			}
		}
		System.out.println(Max);
		System.out.println(String.join(" ", J));
	}

}
0