#include #include #include #include #include #include #include #include #include #include #include #include #include #define pb push_back #define puts(x) cout << #x << " : " << x << endl; #pragma GCC diagnostic ignored "-Wconversion" #define REP(i,n) for (int i=0;i<(n);i++) #define REPE(i,n) for (int i=0;i<=(n);i++) #define init(a,b) memset((a), (b), (sizeof(a))); #define PI 3.14159265 #define EPS (1e-10) #define EQ(a,b) (abs((a)-(b)) < EPS) using namespace std; typedef long long ll; //firstは最短距離、secondは頂点の番号 typedef pair P; const int INF = 1000*1000*1000; const int MAX_V=100; // 点の数 const int MAX_M=500; // 金 struct edge { int to, distance, money; }; vector G[MAX_V]; int dp[MAX_V][MAX_M]; int main() { int N, C, V;cin>>N>>C>>V; vector S(V), T(V), Y(V), M(V); for(int i=0;i>S[i];S[i]--;} for(int i=0;i>T[i];T[i]--;} for(int i=0;i>Y[i];} for(int i=0;i>M[i];} for(int i=0;i, greater

> PQ; for(int i=0;i dp[v][money] + e.distance) { dp[e.to][rest_money] = dp[v][money] + e.distance; PQ.push(P(e.to, dp[e.to][rest_money] * 10000 + rest_money)); } } } int mn = INF; for(int i=0;i<300;i++){ if (dp[N-1][i] > 0) mn = min(mn, dp[N-1][i]); } if(mn==INF)cout<<-1<