結果

問題 No.519 アイドルユニット
ユーザー 37zigen37zigen
提出日時 2017-05-29 01:47:10
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 914 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 78,052 KB
実行使用メモリ 126,812 KB
最終ジャッジ日時 2023-10-21 14:55:21
合計ジャッジ時間 14,799 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 389 ms
76,948 KB
testcase_03 AC 160 ms
59,772 KB
testcase_04 AC 100 ms
56,084 KB
testcase_05 AC 109 ms
57,352 KB
testcase_06 AC 112 ms
57,532 KB
testcase_07 AC 122 ms
57,704 KB
testcase_08 AC 120 ms
57,664 KB
testcase_09 AC 135 ms
57,636 KB
testcase_10 AC 130 ms
57,560 KB
testcase_11 AC 148 ms
59,288 KB
testcase_12 AC 102 ms
57,224 KB
testcase_13 AC 145 ms
59,568 KB
testcase_14 AC 147 ms
59,536 KB
testcase_15 AC 150 ms
59,840 KB
testcase_16 AC 148 ms
59,568 KB
testcase_17 AC 154 ms
59,536 KB
testcase_18 AC 152 ms
59,692 KB
testcase_19 AC 145 ms
59,760 KB
testcase_20 AC 151 ms
59,680 KB
testcase_21 AC 153 ms
59,732 KB
testcase_22 AC 155 ms
59,580 KB
testcase_23 AC 156 ms
59,756 KB
testcase_24 AC 190 ms
61,680 KB
testcase_25 AC 195 ms
61,584 KB
testcase_26 AC 186 ms
59,720 KB
testcase_27 AC 190 ms
61,392 KB
testcase_28 AC 191 ms
61,668 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 AC 996 ms
126,812 KB
testcase_33 AC 105 ms
57,168 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 (Integer.bitCount(s) % 2 != 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