結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2014-12-06 23:31:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,587 bytes |
| コンパイル時間 | 749 ms |
| コンパイル使用メモリ | 74,672 KB |
| 実行使用メモリ | 797,156 KB |
| 最終ジャッジ日時 | 2024-07-08 03:37:35 |
| 合計ジャッジ時間 | 7,392 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 7 MLE * 1 -- * 32 |
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> II;
typedef pair<int, II> III;
typedef vector<int> IntVec;
typedef vector<III> IIIVec;
int main(int argc, char *argv[])
{
string s;
getline(cin, s);
int N = atoi(s.c_str());
getline(cin, s);
int C = atoi(s.c_str());
getline(cin, s);
int V = atoi(s.c_str());
IntVec S(V), T(V), Y(V), M(V);
{
getline(cin, s);
stringstream ss(s);
for (int i = 0; i < V; ++i) {
ss >> S[i];
}
}
{
getline(cin, s);
stringstream ss(s);
for (int i = 0; i < V; ++i) {
ss >> T[i];
}
}
{
getline(cin, s);
stringstream ss(s);
for (int i = 0; i < V; ++i) {
ss >> Y[i];
}
}
{
getline(cin, s);
stringstream ss(s);
for (int i = 0; i < V; ++i) {
ss >> M[i];
}
}
IIIVec v[64];
for (int i = 0; i < V; ++i) {
v[S[i] - 1].push_back(III(-Y[i], II(T[i] - 1, M[i])));
}
int ans = 1 << 30;
priority_queue<III> q;
for (int i = 0; i < v[0].size(); ++i) {
q.push(v[0][i]);
}
while (q.size() > 0) {
III current = q.top();
q.pop();
int pos = current.second.first;
if (pos == N - 1) {
ans = min(ans, current.second.second);
}
for (int i = 0; i < v[pos].size(); ++i) {
III &e = v[pos][i];
int cost = current.first + e.first;
if (-cost <= C) {
int time = current.second.second + e.second.second;
q.push(III(cost, II(e.second.first, time)));
}
}
}
cout << (ans < (1<<30) ? ans : -1) << endl;
return 0;
}
hotpepsi