結果

問題 No.1 道のショートカット
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-23 12:49:32
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,601 bytes
コンパイル時間 2,090 ms
コンパイル使用メモリ 73,700 KB
実行使用メモリ 829,044 KB
最終ジャッジ日時 2023-09-22 12:03:51
合計ジャッジ時間 12,168 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 212 ms
80,416 KB
testcase_02 AC 214 ms
79,944 KB
testcase_03 AC 197 ms
60,252 KB
testcase_04 AC 141 ms
55,916 KB
testcase_05 AC 218 ms
80,212 KB
testcase_06 AC 199 ms
60,944 KB
testcase_07 AC 278 ms
68,156 KB
testcase_08 MLE -
testcase_09 MLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

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();
        }
        for(int i=0; i<v; i++){
            m[i]=koko.nextInt();
        }
        boolean[][][] stop = new boolean[n+1][c+1][49001]; 
        stop[1][0][0]=true;
        for(int i=2; i<n+1; i++){
            for(int j=0; j<v; j++){
                if(i==t[j]){
                    for(int cost=0; cost<c+1; cost++){
                        for(int time=0; time<49001; time++){
                            if(stop[s[j]][cost][time]&&cost+y[j]<c+1){
                                stop[i][cost+y[j]][time+m[j]]=true;
                            }
                        }
                    }
                }
            }
        }
        boolean flag = false;
loop1:  for(int i=0; i<49001; i++){
            for(int cost=0; cost<c+1; cost++){
                if(stop[n][cost][i]){
                    System.out.println(i);
                    flag=true;
                    break loop1;
                }
            }
        }
        if(!flag){
            System.out.println(-1);
        }
    }
}
0