結果
問題 |
No.1 道のショートカット
|
ユーザー |
![]() |
提出日時 | 2015-04-18 11:43:57 |
言語 | Java (openjdk 23) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,546 bytes |
コンパイル時間 | 1,672 ms |
コンパイル使用メモリ | 76,952 KB |
実行使用メモリ | 767,324 KB |
最終ジャッジ日時 | 2024-07-08 03:52:29 |
合計ジャッジ時間 | 23,269 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 MLE * 10 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner koko = new Scanner(System.in); int n = koko.nextInt(); int c = koko.nextInt(); int v = koko.nextInt(); int[] s = new int[v]; int[] t = new int[v]; int[] y = new int[v]; int[] m = new int[v]; for(int i=0; i<v; i++){ s[i]=koko.nextInt(); } for(int i=0; i<v; i++){ t[i]=koko.nextInt(); } for(int i=0; i<v; i++){ y[i]=koko.nextInt(); } int tm=0; for(int i=0; i<v; i++){ m[i]=koko.nextInt(); tm=tm+m[i]; } boolean[][][] judge = new boolean[n+1][c+1][tm+1]; judge[1][0][0]=true; for(int i=0; i<c; i++){ for(int j=0; j<n+1; j++){ for(int k=0; k<tm+1; k++){ if(judge[j][i][k]){ for(int l=0; l<v; l++){ if(j==s[l]&&i+y[l]<=c){ judge[t[l]][i+y[l]][k+m[l]]=true; } } } } } } boolean wflag = false; loop1: for(int i=0; i<tm+1; i++){ for(int j=0; j<c+1; j++){ if(judge[n][j][i]){ wflag=true; System.out.println(i); break loop1; } } } if(!wflag){ System.out.println(-1); } } }