結果

問題 No.1 道のショートカット
ユーザー kou6839kou6839
提出日時 2014-11-08 00:43:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,585 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 75,080 KB
実行使用メモリ 61,220 KB
最終ジャッジ日時 2023-09-22 11:45:21
合計ジャッジ時間 11,929 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,760 KB
testcase_01 AC 124 ms
55,780 KB
testcase_02 AC 124 ms
55,748 KB
testcase_03 AC 131 ms
56,404 KB
testcase_04 AC 126 ms
55,616 KB
testcase_05 AC 125 ms
55,464 KB
testcase_06 AC 157 ms
57,564 KB
testcase_07 AC 139 ms
55,680 KB
testcase_08 AC 203 ms
59,184 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 WA -
testcase_17 RE -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 222 ms
59,256 KB
testcase_24 AC 205 ms
59,600 KB
testcase_25 AC 191 ms
56,100 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 RE -
testcase_29 AC 231 ms
59,636 KB
testcase_30 WA -
testcase_31 AC 206 ms
59,020 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 205 ms
59,256 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 RE -
testcase_43 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 
class miti{
	int now;
	int to;
	int cost;
	int time;
	miti(int now,int to,int cost,int time){
		this.now = now;
		this.to = to;
		this.cost=cost;
		this.time = time;
	}
}
class mitiComparator implements Comparator<miti>{

	@Override
	public int compare(miti o1, miti o2) {
		if(o1.now>o2.now){
			return 1;
		}else if(o1.now==o2.now){
			return 0;
		}else{
			return -1;
		}
	}
	
}
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int C =sc.nextInt();
		int V=sc.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]=sc.nextInt();
		}
		for(int i=0;i<V;i++){
			T[i]=sc.nextInt();
		}
		for(int i=0;i<V;i++){
			Y[i]=sc.nextInt();
		}
		for(int i=0;i<V;i++){
			M[i]=sc.nextInt();
		}
		miti[] miti1=new miti[V];
		for(int i=0;i<V;i++){
			miti1[i]=new miti(S[i],T[i],Y[i],M[i]);
		}
		Arrays.sort(miti1,new mitiComparator());

		int[] sumc =new int[V+1];
		int[] sumt = new int[V+1];
		for(int i=2;i<=V;i++){
			sumc[i]=Integer.MAX_VALUE;
			sumt[i]=Integer.MAX_VALUE;
		}
		for(miti a:miti1){
			if(sumc[a.now]==Integer.MAX_VALUE) continue;
			if(sumc[a.now]+a.cost<=C){
			sumc[a.to]=Math.min(sumc[a.to], sumc[a.now]+a.cost);
			}else{
				continue;
			}
			sumt[a.to]=Math.min(sumt[a.to], sumc[a.now]+a.time);
		}
		if(sumc[N]<Integer.MAX_VALUE){
			System.out.println(sumt[N]);
		}else{
			System.out.println(-1);
		}
	}
}
0