結果

問題 No.1 道のショートカット
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-18 11:43:57
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,546 bytes
コンパイル時間 3,524 ms
コンパイル使用メモリ 73,652 KB
実行使用メモリ 769,884 KB
最終ジャッジ日時 2023-09-22 12:05:06
合計ジャッジ時間 26,550 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,660 KB
testcase_01 AC 119 ms
56,000 KB
testcase_02 AC 123 ms
55,920 KB
testcase_03 AC 129 ms
56,092 KB
testcase_04 AC 122 ms
57,900 KB
testcase_05 AC 121 ms
55,748 KB
testcase_06 AC 128 ms
56,316 KB
testcase_07 AC 135 ms
56,352 KB
testcase_08 AC 591 ms
190,924 KB
testcase_09 MLE -
testcase_10 MLE -
testcase_11 AC 830 ms
191,248 KB
testcase_12 MLE -
testcase_13 MLE -
testcase_14 AC 973 ms
352,056 KB
testcase_15 AC 149 ms
60,364 KB
testcase_16 MLE -
testcase_17 AC 200 ms
71,944 KB
testcase_18 AC 257 ms
72,480 KB
testcase_19 AC 251 ms
78,936 KB
testcase_20 AC 364 ms
112,256 KB
testcase_21 AC 299 ms
86,264 KB
testcase_22 AC 210 ms
65,176 KB
testcase_23 AC 1,068 ms
113,224 KB
testcase_24 AC 1,074 ms
135,732 KB
testcase_25 AC 357 ms
85,544 KB
testcase_26 AC 260 ms
68,252 KB
testcase_27 AC 1,431 ms
260,576 KB
testcase_28 AC 143 ms
55,796 KB
testcase_29 AC 387 ms
79,032 KB
testcase_30 AC 222 ms
59,680 KB
testcase_31 AC 250 ms
59,744 KB
testcase_32 MLE -
testcase_33 MLE -
testcase_34 MLE -
testcase_35 AC 304 ms
66,156 KB
testcase_36 MLE -
testcase_37 AC 515 ms
130,040 KB
testcase_38 AC 564 ms
188,272 KB
testcase_39 MLE -
testcase_40 AC 946 ms
311,640 KB
testcase_41 AC 371 ms
128,292 KB
testcase_42 AC 158 ms
58,424 KB
testcase_43 AC 155 ms
64,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
       }
   }
}
0