結果

問題 No.1 道のショートカット
ユーザー rokahikou1rokahikou1
提出日時 2019-09-01 12:40:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,437 bytes
コンパイル時間 982 ms
コンパイル使用メモリ 107,604 KB
実行使用メモリ 10,096 KB
最終ジャッジ日時 2023-09-22 13:34:58
合計ジャッジ時間 2,916 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

using tp = tuple<int,int,int>;

int main(){
    int N,C,V;
    cin >> N >> C >> V;
    vector<int> S(V),T(V),Y(V),M(V);
    rep(i,V)cin >> S[i];
    rep(i,V)cin >> T[i];
    rep(i,V)cin >> Y[i];
    rep(i,V)cin >> M[i];
    
    vector<vector<tp> >G(N);

    rep(i,V){
        G[S[i]-1].push_back(make_tuple(T[i]-1,Y[i],M[i]));
    }
    const int INF =1<<30;
    priority_queue<tp,vector<tp>,greater<tp> > que;
    vector<vector<int> > d(N,vector<int>(C+1,INF));//d:=(time,cost)
    d[0][0]=0;
    que.push(make_tuple(0,0,0));

    while(!que.empty()){
        tp a = que.top();que.pop();
        int time,v,cost;
        tie(time,v,cost)=a;
        if(d[v][cost]<time)continue;
        for(tp e:G[v]){
            int nv,adc,adt;
            tie(nv,adc,adt)= e;
            if(d[nv][cost]<d[v][cost]+adt||cost+adc>C)continue;
            d[nv][cost+adc]=d[v][cost]+adt;
            que.push(make_tuple(d[nv][cost+adc],nv,cost+adc));
        }
    }

    int res = INF;
    rep(i,C+1)res = min(res,d[N-1][i]);
    cout << (res==INF?-1:res) << endl;
    return 0;
}
0