結果

問題 No.519 アイドルユニット
ユーザー uafr_csuafr_cs
提出日時 2017-11-08 14:29:18
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 880 bytes
コンパイル時間 3,705 ms
コンパイル使用メモリ 74,012 KB
実行使用メモリ 134,128 KB
最終ジャッジ日時 2023-08-15 21:12:02
合計ジャッジ時間 7,857 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static long MOD = 1000000007;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		
		final int max = 1000;
		int[][] adj = new int[n][n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				adj[i][j] = max - sc.nextInt();
			}
		}
		
		int[] DP = new int[1 << n];
		Arrays.fill(DP, Integer.MAX_VALUE / 2 - 1);
		DP[0] = 0;
		
		for(int bit = 0; bit < (1 << n); bit++){
			for(int i = 0; i < n; i++){
				final int fst = 1 << i;
				
				for(int j = i + 1; j < n; j++){
					final int snd = 1 << j;
					
					final int next_bit = bit | fst | snd;
					DP[next_bit] = Math.min(DP[next_bit], DP[bit] + adj[i][j]);
				}
			}
		}
		
		System.out.println(max * (n / 2) - DP[(1 << n) - 1]);
	}
}
0