結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,160 KB
testcase_01 AC 134 ms
41,296 KB
testcase_02 AC 135 ms
41,360 KB
testcase_03 AC 126 ms
42,012 KB
testcase_04 AC 124 ms
41,116 KB
testcase_05 AC 132 ms
41,768 KB
testcase_06 AC 138 ms
41,812 KB
testcase_07 AC 137 ms
41,372 KB
testcase_08 AC 121 ms
40,448 KB
testcase_09 AC 130 ms
41,432 KB
testcase_10 AC 122 ms
41,584 KB
testcase_11 AC 132 ms
41,728 KB
testcase_12 AC 138 ms
41,260 KB
testcase_13 AC 138 ms
41,792 KB
testcase_14 AC 139 ms
41,500 KB
testcase_15 AC 137 ms
41,704 KB
testcase_16 AC 139 ms
41,560 KB
testcase_17 AC 138 ms
41,320 KB
testcase_18 AC 133 ms
41,260 KB
testcase_19 AC 140 ms
41,844 KB
testcase_20 AC 144 ms
41,532 KB
testcase_21 AC 124 ms
40,124 KB
testcase_22 AC 143 ms
41,700 KB
testcase_23 AC 250 ms
47,036 KB
testcase_24 AC 297 ms
46,936 KB
testcase_25 AC 406 ms
47,172 KB
testcase_26 AC 191 ms
43,804 KB
testcase_27 AC 151 ms
42,752 KB
testcase_28 AC 355 ms
47,864 KB
testcase_29 AC 201 ms
46,356 KB
testcase_30 AC 248 ms
47,368 KB
testcase_31 AC 246 ms
47,084 KB
testcase_32 AC 190 ms
44,760 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 126 ms
41,600 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();
		int Max = Integer.MIN_VALUE;
		int Max_comb = -1;
		for (int i=0; i < 1 << N; i++) {
			int 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