結果

問題 No.519 アイドルユニット
ユーザー 37zigen37zigen
提出日時 2017-05-29 01:49:39
言語 Java19
(openjdk 21)
結果
AC  
実行時間 267 ms / 1,000 ms
コード長 887 bytes
コンパイル時間 1,909 ms
コンパイル使用メモリ 74,392 KB
実行使用メモリ 125,556 KB
最終ジャッジ日時 2023-07-26 17:02:37
合計ジャッジ時間 9,403 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 254 ms
123,272 KB
testcase_01 AC 267 ms
125,492 KB
testcase_02 AC 202 ms
75,792 KB
testcase_03 AC 159 ms
58,184 KB
testcase_04 AC 119 ms
56,048 KB
testcase_05 AC 124 ms
55,692 KB
testcase_06 AC 129 ms
54,004 KB
testcase_07 AC 129 ms
55,664 KB
testcase_08 AC 134 ms
56,188 KB
testcase_09 AC 139 ms
55,920 KB
testcase_10 AC 144 ms
56,020 KB
testcase_11 AC 164 ms
57,908 KB
testcase_12 AC 121 ms
55,940 KB
testcase_13 AC 163 ms
57,684 KB
testcase_14 AC 158 ms
57,856 KB
testcase_15 AC 163 ms
57,960 KB
testcase_16 AC 158 ms
57,692 KB
testcase_17 AC 158 ms
57,788 KB
testcase_18 AC 160 ms
58,288 KB
testcase_19 AC 160 ms
58,148 KB
testcase_20 AC 161 ms
58,200 KB
testcase_21 AC 159 ms
58,144 KB
testcase_22 AC 158 ms
58,156 KB
testcase_23 AC 157 ms
57,976 KB
testcase_24 AC 182 ms
60,056 KB
testcase_25 AC 170 ms
60,224 KB
testcase_26 AC 170 ms
60,092 KB
testcase_27 AC 181 ms
60,036 KB
testcase_28 AC 184 ms
60,372 KB
testcase_29 AC 250 ms
125,312 KB
testcase_30 AC 261 ms
125,464 KB
testcase_31 AC 262 ms
125,144 KB
testcase_32 AC 266 ms
125,556 KB
testcase_33 AC 120 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] f = new int[n][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				f[i][j] = sc.nextInt();
			}
		}

		int[] g = new int[1 << n];
		Arrays.fill(g, -Integer.MAX_VALUE / 16);
		g[0] = 0;
		for (int s = 0; s < (1 << n); ++s) {
			if (g[s] < 0)
				continue;
			int o = Integer.numberOfTrailingZeros(~s);
			for (int i = o + 1; i < n; ++i) {
				if (((1L << i) & s) > 0) {
					continue;
				}
				int ne = s | (1 << i) | (1 << o);
				g[ne] = Math.max(g[ne], g[s] + f[i][o]);
			}
		}

		System.out.println(g[(1 << n) - 1]);
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0