結果

問題 No.1 道のショートカット
ユーザー AquaplusAquaplus
提出日時 2018-02-10 19:14:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,765 bytes
コンパイル時間 1,053 ms
コンパイル使用メモリ 96,868 KB
実行使用メモリ 5,256 KB
最終ジャッジ日時 2023-09-22 13:16:05
合計ジャッジ時間 2,736 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <utility>
using namespace std;

int main(void)
{
    int n, c, v;
    cin >> n >> c >> v;

    int s[v], t[v], y[v], m[v];
    pair<int, int> p1, p2;
    map<pair<int, int>, pair<int, int> > mp;
    vector<int> zero(0);
    vector<vector<int> > arr(n + 1, zero);
    vector<int> cost(n + 1, 0);
    vector<int> time(n + 1, 0);
    vector<bool> pass(n + 1, false);

    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++)
    {
        mp[make_pair(s[i], t[i])] = make_pair(y[i], m[i]);
        arr[s[i]].push_back(t[i]);
    }

    int x = 1;
    pass[1] = true;

    cout << "Nysnpasu" << endl;
    while (x != n)
    {
        for (int i = 0; i < arr[x].size(); i++)
        {
            if (cost[x] + mp[make_pair(x, arr[x][i])].first <= c)
            {
                cost[arr[x][i]] = cost[x] + mp[make_pair(x, arr[x][i])].first;
                time[arr[x][i]] = time[x] + mp[make_pair(x, arr[x][i])].second;
            }
        }

        pass[x] = true;
        x = 0;
        for (int i = 2; i <= n; i++)
            if (!pass[i]&&time[i]>0)
            {
                x = i;
                break;
            }

        if (x == 0)
        {
            cout << -1 << endl;
            return 0;
        }

        for (int i = x; i <= n; i++)
        {
            if (!pass[i] && time[x] > time[i] && time[i] > 0)
                x = i;
        }
    }

    cout << time[n] << endl;
    return 0;
}
0