結果

問題 No.519 アイドルユニット
ユーザー 37zigen37zigen
提出日時 2017-05-29 01:49:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 278 ms / 1,000 ms
コード長 887 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 77,480 KB
実行使用メモリ 123,724 KB
最終ジャッジ日時 2024-04-14 06:37:52
合計ジャッジ時間 9,871 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 275 ms
123,564 KB
testcase_01 AC 269 ms
123,340 KB
testcase_02 AC 221 ms
73,916 KB
testcase_03 AC 169 ms
56,420 KB
testcase_04 AC 133 ms
53,956 KB
testcase_05 AC 137 ms
54,256 KB
testcase_06 AC 140 ms
54,220 KB
testcase_07 AC 139 ms
53,976 KB
testcase_08 AC 145 ms
54,284 KB
testcase_09 AC 146 ms
54,296 KB
testcase_10 AC 153 ms
54,096 KB
testcase_11 AC 176 ms
56,580 KB
testcase_12 AC 131 ms
54,268 KB
testcase_13 AC 168 ms
56,476 KB
testcase_14 AC 179 ms
56,168 KB
testcase_15 AC 176 ms
56,360 KB
testcase_16 AC 173 ms
56,476 KB
testcase_17 AC 167 ms
56,452 KB
testcase_18 AC 171 ms
56,392 KB
testcase_19 AC 165 ms
56,292 KB
testcase_20 AC 166 ms
56,472 KB
testcase_21 AC 170 ms
56,568 KB
testcase_22 AC 169 ms
56,384 KB
testcase_23 AC 178 ms
56,444 KB
testcase_24 AC 204 ms
58,520 KB
testcase_25 AC 187 ms
58,388 KB
testcase_26 AC 198 ms
58,480 KB
testcase_27 AC 199 ms
58,268 KB
testcase_28 AC 198 ms
58,600 KB
testcase_29 AC 274 ms
123,576 KB
testcase_30 AC 278 ms
123,724 KB
testcase_31 AC 264 ms
123,348 KB
testcase_32 AC 278 ms
123,536 KB
testcase_33 AC 132 ms
54,252 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