結果

問題 No.519 アイドルユニット
ユーザー uafr_csuafr_cs
提出日時 2017-11-08 14:42:23
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 919 bytes
コンパイル時間 2,064 ms
コンパイル使用メモリ 74,320 KB
実行使用メモリ 125,620 KB
最終ジャッジ日時 2023-08-15 21:12:45
合計ジャッジ時間 18,252 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 126 ms
55,848 KB
testcase_05 AC 128 ms
55,848 KB
testcase_06 AC 133 ms
55,780 KB
testcase_07 AC 135 ms
55,528 KB
testcase_08 AC 145 ms
56,212 KB
testcase_09 AC 155 ms
55,912 KB
testcase_10 AC 170 ms
55,892 KB
testcase_11 AC 184 ms
58,084 KB
testcase_12 AC 125 ms
55,844 KB
testcase_13 AC 183 ms
57,744 KB
testcase_14 AC 186 ms
58,240 KB
testcase_15 AC 187 ms
58,056 KB
testcase_16 AC 186 ms
58,048 KB
testcase_17 AC 186 ms
58,288 KB
testcase_18 WA -
testcase_19 AC 182 ms
57,992 KB
testcase_20 AC 190 ms
57,796 KB
testcase_21 AC 188 ms
57,820 KB
testcase_22 AC 188 ms
57,708 KB
testcase_23 AC 187 ms
59,876 KB
testcase_24 AC 231 ms
60,272 KB
testcase_25 AC 220 ms
60,332 KB
testcase_26 AC 231 ms
60,004 KB
testcase_27 AC 240 ms
59,860 KB
testcase_28 WA -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 125 ms
55,492 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