結果

問題 No.1 道のショートカット
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2017-01-03 10:39:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,127 bytes
コンパイル時間 1,258 ms
コンパイル使用メモリ 156,080 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-09-22 12:53:35
合計ジャッジ時間 2,794 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int n, c, v;
int s[1510], t[1510], y[1510], m[1510];

vector<tuple<int, int, int> > G[110];
//dist[u][money] := 現在の頂点がuで残りのお金がmoney
int dist[52][310];

void dijkstra(int start){
    rep(i, 52)rep(j, 310) dist[i][j] = INF; 
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int> >, greater<tuple<int, int, int> > >  que;
    que.push(make_tuple(0, start, c));//時間 現在の頂点 残りの金
    dist[0][c] = 0;
    while(!que.empty()){
        int time, u, money;//今までにかかった時間 現在の頂点 残りの金
        tie(time, u, money) = que.top(); que.pop();
        if(dist[u][money] < time) continue;
		        
        for (auto tmp : G[u]){
            int v, now_money, now_time;//v u->vの金 u->vの時間
            tie(v, now_money, now_time) = tmp;
            if(money - now_money < 0) continue;
            if(dist[v][money - now_money] > dist[u][money] + now_time){
	            dist[v][money - now_money] = dist[u][money] + now_time;
	            que.push(make_tuple(dist[v][money - now_money], v, money - now_money));
	        }
        }   
    }   
}

int main(void){
	scanf("%d %d %d", &n, &c, &v);
	rep(i, v) scanf("%d", &s[i]), s[i]--;
	rep(i, v) scanf("%d", &t[i]), t[i]--;
	rep(i, v) scanf("%d", &y[i]);
	rep(i, v) scanf("%d", &m[i]);
	rep(i, v){
		G[s[i]].pb(make_tuple(t[i], y[i], m[i]));//s->t y:=お金 m:= 時間
	}
	dijkstra(0);
	int ans = INF;
	rep(i, 52) chmin(ans, dist[n - 1][i]);
	if(ans == INF)printf("-1\n");
	else printf("%d\n", ans);
	return 0;
}
0