結果
問題 | No.90 品物の並び替え |
ユーザー | kou6839 |
提出日時 | 2014-12-09 00:12:19 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,068 ms / 5,000 ms |
コード長 | 1,173 bytes |
コンパイル時間 | 2,507 ms |
コンパイル使用メモリ | 77,548 KB |
実行使用メモリ | 67,144 KB |
最終ジャッジ日時 | 2023-09-02 11:54:22 |
合計ジャッジ時間 | 6,506 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 133 ms
55,804 KB |
testcase_01 | AC | 324 ms
63,780 KB |
testcase_02 | AC | 128 ms
55,912 KB |
testcase_03 | AC | 199 ms
58,196 KB |
testcase_04 | AC | 209 ms
59,024 KB |
testcase_05 | AC | 359 ms
65,236 KB |
testcase_06 | AC | 312 ms
64,072 KB |
testcase_07 | AC | 162 ms
58,388 KB |
testcase_08 | AC | 129 ms
56,100 KB |
testcase_09 | AC | 1,068 ms
67,144 KB |
ソースコード
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+=ww.get(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); } }