結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
ojisan_IT
|
| 提出日時 | 2017-08-11 06:37:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,675 bytes |
| コンパイル時間 | 1,549 ms |
| コンパイル使用メモリ | 168,288 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-08 04:56:59 |
| 合計ジャッジ時間 | 2,876 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 WA * 5 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
int dp[51][301] ={}; // dp[N][C] = time
struct edge{
int to,cost,time;
};
vector<edge> G[51];
vi s(1500),t(1500),y(1500),m(1500);
int main(){
int n,c,v; cin >> n>> c >> 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];
rep(i,v)
G[s[i]].pb((edge){t[i],y[i],m[i]});
fill_n(dp[0],51*301,INF);
priority_queue<pii,vector<pii>,greater<pii > > q; //cost,position
dp[1][c] = 0;
q.push(mp(c,1));
while(!q.empty()){
int id = q.top().SEC;
int nowc = q.top().FST;
q.pop();
for(int i = 0; i < G[id].size();i++){
if(nowc-G[id][i].cost>=0 && dp[id][nowc]+G[id][i].time < dp[G[id][i].to][nowc-G[id][i].cost]){
dp[G[id][i].to][nowc-G[id][i].cost]=dp[id][nowc]+G[id][i].time;
q.push(mp(nowc-G[id][i].cost,G[id][i].to));
}
}
}
int ans = INF;
for(int i = 0; i <= 301; i++)
ans = min(ans,dp[n][i]);
cout << ((ans == INF)? -1 : ans) << endl;
}
ojisan_IT