結果
| 問題 | 
                            No.90 品物の並び替え
                             | 
                    
| コンテスト | |
| ユーザー | 
                             uafr_cs
                         | 
                    
| 提出日時 | 2015-05-15 18:25:17 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,222 bytes | 
| コンパイル時間 | 2,091 ms | 
| コンパイル使用メモリ | 77,044 KB | 
| 実行使用メモリ | 54,256 KB | 
| 最終ジャッジ日時 | 2024-07-06 03:59:01 | 
| 合計ジャッジ時間 | 4,425 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 1 WA * 8 | 
ソースコード
/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static int dfs(final int N, int deep, boolean[] selected, int[] items, int[][] scores){
		if(deep < N){
			int max = Integer.MIN_VALUE;
			for(int i = 0; i < N; i++){
				if(!selected[i]){
					selected[i] = true;
					items[deep] = i;
					max = dfs(N, deep + 1, selected, items, scores);
					selected[i] = false;
				}
			}
			
			return max;
		}else{
			int score = 0;
			for(int fst = 0; fst < N; fst++){
				for(int snd = fst + 1; snd < N; snd++){
					score += scores[items[fst]][items[snd]];
				}
			}
			
			return score;
		}
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		int[][] scores = new int[N][N];
		
		for(int i = 0; i < M; i++){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			final int score = sc.nextInt();
			
			scores[A][B] = Math.max(scores[A][B], score);
		}
		
		System.out.println(dfs(N, 0, new boolean[N], new int[N], scores));
	}
}
            
            
            
        
            
uafr_cs