結果

問題 No.519 アイドルユニット
ユーザー uafr_csuafr_cs
提出日時 2017-11-08 14:42:23
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 919 bytes
コンパイル時間 2,005 ms
コンパイル使用メモリ 77,792 KB
実行使用メモリ 124,444 KB
最終ジャッジ日時 2024-05-03 07:46:32
合計ジャッジ時間 15,508 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 103 ms
52,680 KB
testcase_05 AC 105 ms
54,188 KB
testcase_06 AC 124 ms
54,192 KB
testcase_07 AC 121 ms
54,008 KB
testcase_08 AC 129 ms
54,152 KB
testcase_09 AC 133 ms
54,196 KB
testcase_10 AC 145 ms
54,216 KB
testcase_11 AC 173 ms
56,336 KB
testcase_12 AC 120 ms
54,020 KB
testcase_13 AC 166 ms
58,448 KB
testcase_14 AC 176 ms
56,452 KB
testcase_15 AC 164 ms
56,464 KB
testcase_16 AC 172 ms
56,260 KB
testcase_17 AC 180 ms
56,272 KB
testcase_18 WA -
testcase_19 AC 170 ms
56,336 KB
testcase_20 AC 161 ms
56,684 KB
testcase_21 AC 176 ms
56,012 KB
testcase_22 AC 170 ms
56,448 KB
testcase_23 AC 165 ms
56,296 KB
testcase_24 AC 209 ms
58,420 KB
testcase_25 AC 211 ms
58,460 KB
testcase_26 AC 229 ms
58,740 KB
testcase_27 AC 230 ms
59,140 KB
testcase_28 WA -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 113 ms
52,792 KB
権限があれば一括ダウンロードができます

ソースコード

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++){
			//System.out.println(bit);
			int i = 0;
			for (; (bit & (1 << i)) != 0; ++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