結果

問題 No.519 アイドルユニット
ユーザー uafr_csuafr_cs
提出日時 2017-11-08 15:29:41
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,080 bytes
コンパイル時間 2,191 ms
コンパイル使用メモリ 75,096 KB
実行使用メモリ 125,660 KB
最終ジャッジ日時 2023-08-15 21:13:19
合計ジャッジ時間 16,283 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 108 ms
56,168 KB
testcase_05 AC 108 ms
55,880 KB
testcase_06 AC 111 ms
56,124 KB
testcase_07 AC 115 ms
55,636 KB
testcase_08 AC 120 ms
56,132 KB
testcase_09 AC 130 ms
55,924 KB
testcase_10 AC 137 ms
56,176 KB
testcase_11 AC 157 ms
58,192 KB
testcase_12 AC 106 ms
55,904 KB
testcase_13 AC 152 ms
58,220 KB
testcase_14 AC 157 ms
58,036 KB
testcase_15 AC 162 ms
58,356 KB
testcase_16 AC 152 ms
57,740 KB
testcase_17 AC 160 ms
57,740 KB
testcase_18 WA -
testcase_19 AC 159 ms
58,164 KB
testcase_20 AC 161 ms
58,116 KB
testcase_21 AC 152 ms
57,960 KB
testcase_22 AC 153 ms
58,112 KB
testcase_23 AC 154 ms
58,296 KB
testcase_24 AC 184 ms
60,524 KB
testcase_25 AC 182 ms
60,104 KB
testcase_26 AC 204 ms
60,576 KB
testcase_27 AC 203 ms
60,228 KB
testcase_28 WA -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 108 ms
55,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	
	public static int solve_DP(int n, int[][] adj){
		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++){
			if(DP[bit] < 0){ continue; }
			
			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]);
			}
		}
		
		return DP[(1 << n) - 1];
	}
	
	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();
			}
		}
		
		final int solve = solve_DP(n, adj);
		
		System.out.println(max * (n / 2) - solve);
	}
}
0