結果

問題 No.90 品物の並び替え
ユーザー kou6839kou6839
提出日時 2014-12-09 00:10:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,165 bytes
コンパイル時間 4,402 ms
コンパイル使用メモリ 77,080 KB
実行使用メモリ 66,752 KB
最終ジャッジ日時 2023-09-02 11:54:15
合計ジャッジ時間 7,054 ms
ジャッジサーバーID
(参考情報)
judge16 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
56,956 KB
testcase_01 WA -
testcase_02 AC 169 ms
56,888 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 171 ms
56,544 KB
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;
 
public class Main {
	static int[] i1;
	static int[] i2;
	static int[] ten;
	static int ans=0;
	static int r;
	static int g;
	static void check(String now,ArrayList<Integer> ww){
		if(now.length()==r){
			eee(now);
			return;
		}
		for(int i=0;i<ww.size();i++){
			String ttt=new String(now);
			ttt+=i;
			int eee=ww.get(i);
			ww.remove(i);
			check(ttt,ww);
			ww.add(i, eee);
		}
	}
	static void eee(String now){
		int temp=0;
		for(int i=0;i<g;i++){
			if(now.indexOf(i1[i]+"")<now.indexOf(i2[i]+"") ) temp+=ten[i];
		}
		ans=Math.max(ans, temp);
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        r = sc.nextInt();
        g = sc.nextInt();
        ArrayList<Integer> uuu= new ArrayList<>();
        i1 = new int[g];
        i2=new int[g];
        ten = new int[g];
        for(int i=0;i<g;i++){
        	i1[i]=sc.nextInt();
        	i2[i]=sc.nextInt();
        	ten[i]=sc.nextInt();
        }
        for(int i=0;i<r;i++){
        	uuu.add(i);
        }
        check("",uuu);
        System.out.println(ans);
    }
}
0