結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
d2verb
|
| 提出日時 | 2015-05-05 00:17:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,387 bytes |
| コンパイル時間 | 765 ms |
| コンパイル使用メモリ | 87,848 KB |
| 実行使用メモリ | 10,144 KB |
| 最終ジャッジ日時 | 2024-07-08 03:56:14 |
| 合計ジャッジ時間 | 12,740 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 TLE * 2 -- * 20 |
ソースコード
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <complex>
using namespace std;
#define INF (INT_MAX/3)
#define PI (2*acos(0.0))
#define EPS (1e-8)
typedef long long ll;
typedef unsigned long long ull;
int N, C, V, data[4][1500];
int ans = INF;
struct edge{
int to, cost, time;
edge(int to, int cost, int time){
this->to = to;
this->cost = cost;
this->time = time;
}
};
vector<edge> G[51];
void solve(int n, int t, int c){
if(n == N){
if(c <= C) ans = min(ans, t);
return;
}
if(c > C) return;
for(int i = 0; i < G[n].size(); i++){
solve(G[n][i].to, t + G[n][i].time, c + G[n][i].cost);
}
}
int main(){
ios_base::sync_with_stdio(0);
cin >> N >> C >> V;
for(int i = 0; i < 4; i++){
for(int j = 0; j < V; j++) cin >> data[i][j];
}
for(int i = 0; i < V; i++){
int s = data[0][i], t = data[1][i];
int y = data[2][i], m = data[3][i];
G[s].push_back(edge(t, y, m));
}
solve(1, 0, 0);
if(ans == INF) cout << -1 << endl;
else cout << ans << endl;
return 0;
}
d2verb