結果
問題 |
No.90 品物の並び替え
|
ユーザー |
![]() |
提出日時 | 2014-12-09 13:32:16 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 248 ms / 5,000 ms |
コード長 | 1,060 bytes |
コンパイル時間 | 2,441 ms |
コンパイル使用メモリ | 77,956 KB |
実行使用メモリ | 54,500 KB |
最終ジャッジ日時 | 2024-06-11 18:51:37 |
合計ジャッジ時間 | 3,910 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
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 int isUsed=0; static int[] a; static void check(int now){ if(now==r){ eee(); return; } for(int i=0;i<r;i++){ if( (isUsed&1<<i)!=0) continue; isUsed+=1<<i; a[i]=now; check(now+1); isUsed-=1<<i; } } static void eee(){ int temp=0; for(int i=0;i<g;i++){ if(a[i1[i]]<a[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(); a= new int[r]; 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(); } check(0); System.out.println(ans); } }