結果
問題 |
No.1 道のショートカット
|
ユーザー |
![]() |
提出日時 | 2014-11-24 01:03:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,050 bytes |
コンパイル時間 | 811 ms |
コンパイル使用メモリ | 73,852 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-08 03:35:40 |
合計ジャッジ時間 | 2,063 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 16 WA * 24 |
ソースコード
#include <iostream> #include <algorithm> #include <map> using namespace std; typedef struct data{ int money; int time; }data; int N, C, V; int S[1500], T[1500], Y[1500], M[1500]; map<int, map<int,data> > keiro; int loop(int pos, int money, int time, int min_time){ if(money<0 || (min_time<time && min_time!=-1)){ return -1; } if(pos == N){ return time; } for(int i=1; i<=N; i++){ if(keiro[pos].find(i) != keiro[pos].end()){ int tmp = loop(i, money-keiro[pos][i].money, time+keiro[pos][i].time, min_time); min_time = (tmp==-1)? min_time : tmp; } } return min_time; } int main(int argc, char const *argv[]) { cin >> N >> C >> V; for (int i = 0; i < V; ++i){ cin >> S[i]; } for (int i = 0; i < V; ++i){ cin >> T[i]; } for (int i = 0; i < V; ++i){ cin >> Y[i]; } for (int i = 0; i < V; ++i){ cin >> M[i]; } for (int i = 0; i < V; ++i){ keiro[S[i]][T[i]].money = Y[i]; keiro[S[i]][T[i]].time = M[i]; } cout << loop(1, C, 0, -1) << endl; return 0; }