結果

問題 No.1 道のショートカット
ユーザー otamay6otamay6
提出日時 2019-10-17 15:53:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,006 bytes
コンパイル時間 1,819 ms
コンパイル使用メモリ 180,480 KB
実行使用メモリ 64,824 KB
最終ジャッジ日時 2023-09-22 13:38:04
合計ジャッジ時間 8,284 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 TLE -
testcase_09 -- -
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 #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    const int inf=1<<25;
    int N,C,V;cin>>N>>C>>V;
    vector<vector<int>> E(V,vector<int>(4)),dp(N+1,vector<int>(C+1,inf));
    REP(i,4) REP(j,V) cin>>E[j][i];
    vector<vector<tuple<int,int,int>>> to(N);
    REP(i,V){
        int s=E[i][0]-1,t=E[i][1]-1,y=E[i][2],m=E[i][3];
        to[s].push_back(tie(t,y,m));
    }
    queue<int> que;
    que.push(0);
    dp[0][C]=0;
    while(!que.empty()){
        int u=que.front();que.pop();
        REP(i,to[u].size()){
            int v,y,m;
            tie(v,y,m)=to[u][i];
            REP(j,C+1){
                if(j+y<=C) dp[v][j]=min(dp[v][j],dp[u][j+y]+m);
            }
            que.push(v);
        }
    }
    int ans=inf;
    REP(i,C+1) ans=min(ans,dp[N-1][i]);
    if(ans==inf) cout<<-1<<endl;
    else cout<<ans<<endl;
}
0