結果

問題 No.1 道のショートカット
ユーザー AquaplusAquaplus
提出日時 2018-02-10 22:19:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,292 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 88,136 KB
実行使用メモリ 4,564 KB
最終ジャッジ日時 2023-09-22 13:16:53
合計ジャッジ時間 4,925 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;

#define INF 1000000

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

    vector<int> s(v), t(v), y(v), m(v);
    pair<int, int> p1, p2;
    map<pair<int, int>, pair<int, int> >  mp;
    vector<vector<int> > arr(n, vector<int>(0));

    for (int i = 0; i < v; i++)
        scanf("%d", &s[i]);
    for (int i = 0; i < v; i++)
        scanf("%d", &t[i]);
    for (int i = 0; i < v; i++)
        scanf("%d", &y[i]);
    for (int i = 0; i < v; i++)
        scanf("%d", &m[i]);
    vector<vector<int> > time(n+1, vector<int>(c+1, INF));

    time[1][c] = 0;
    for (int i = 1; i <= n; i++)
        for (int j = c; j >= 0; j--)
        {
            if (time[i][j] != INF)
            {
                for(int k = 0; k < v; k++)
                    if(s[k]==i && time[i][j]+m[k]<time[t[k]][j-y[k]])
                    {
                        time[t[k]][j-y[k]] = time[i][j] + m[k];
                    }
            }
        }

    int min = INF;
    for(int i = 0; i <= c; i++)
        if(min > time[n][i])
            min = time[n][i];
    cout << (min==INF?-1:min) << endl;
    return 0;
}
0