#include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)< C ){ return -1; } if( from == N){ return 0; } if( dp[from][cost] != dpINF){ return dp[from][cost]; } int ans = -1; int ansTemp = -1; for(int i = 0; i < E; ++i){//1500 if(s[i] == from){ ansTemp = solve( t[i], cost + y[i] );//next->Nまでのコスト if(ansTemp != -1 ){//たどり着けた ansTemp += m[i];//from->nextのコストを足す if( ans == -1 || ans > ansTemp){ ans = ansTemp; } } } } dp[from][cost] = ans; return ans; } int main(void){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed;// //cout << setprecision(7);// cin >> N; cin >> C; cin >> E; rep(i,E)cin>>s[i];//1からN-1 rep(i,E)cin>>t[i];//2からN rep(i,E)cin>>y[i];//[1,C]円 rep(i,E)cin>>m[i];//[1,1000]時間 //250 [0,50] [0,50] 初期化 rep(i,maxN+1){ rep(j,maxN+1){ rE[i][j] = -1; } } //[0,50][0,300] 15k+300+50+1 初期化 rep(i,maxN+1)rep(j,301)dp[i][j] = dpINF;// P(solve(1,0)); return 0; }