結果

問題 No.1 道のショートカット
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-17 05:45:47
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,073 bytes
コンパイル時間 1,131 ms
コンパイル使用メモリ 26,452 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 12:23:58
合計ジャッジ時間 1,761 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 0 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
4,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 0 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1 ms
4,376 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 0 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <math.h>
#include <string.h>
#include <stdio.h>

#define	NMAX	(50)
#define VMAX	(1500)
#define INF		(99999999)


int cost[NMAX+5][NMAX+5];
int time[NMAX+5][NMAX+5];

int min(int a, int b){
	if(a<b){return a;}
	return b;
	
}

int main(void){
	int money;
	int i,j,k,n,v;
	int s[VMAX+5], t[VMAX+5], y[VMAX+5], m[VMAX+5];
	
	for(i=0;i<=NMAX;i++){
		for(j=0;j<=NMAX;j++){
			cost[i][j] = INF;
			time[i][j] = INF;
		}
	}
	
	scanf("%d", &n);
	scanf("%d", &money);
	scanf("%d", &v);
	
	for(i=0;i<v;i++){	scanf("%d", &s[i]);}
	for(i=0;i<v;i++){	scanf("%d", &t[i]);}
	for(i=0;i<v;i++){	scanf("%d", &y[i]);}
	for(i=0;i<v;i++){	scanf("%d", &m[i]);}
	for(i=0;i<v;i++){
		cost[s[i]][t[i]] = y[i];
		time[s[i]][t[i]] = m[i];
	}
	
	for(k=0;k<=n;k++){
		for(i=0;i<=n;i++){
			for(j=0;j<=n;j++){
				if(cost[i][k] + cost[k][j] > money){continue;}
				
				cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
				time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
			}
		}
	}
	
	if( time[1][n] == INF ){
		printf("-1\n");
	}else{
		printf("%d\n", time[1][n]);
	}
	return 0;
}
0