結果

問題 No.1 道のショートカット
ユーザー Darjeeling0Darjeeling0
提出日時 2020-03-02 18:43:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,850 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 175,196 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 13:41:02
合計ジャッジ時間 3,132 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, W, H, M, C, V;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e7;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    cin >> N >> C >> V;
    vector<ll> c(V), t(V), y(V), m(V);
    REP(i, V){cin >> c[i]; c[i]--;} 
    REP(i, V){cin >> t[i]; t[i]--;}
    REP(i, V) cin >> y[i];
    REP(i, V) cin >> m[i];
    vector<vector<ll>> dp(N, vector<ll> (C + 1, MM));
    vector<vector<ll>> Gcost(N, vector<ll>(N));
    vector<vector<ll>> Gtime(N, vector<ll>(N));
    vector<vector<int>> edge(N);
    REP(i,V){
        Gcost[c[i]][t[i]] = y[i];
        Gtime[c[i]][t[i]] = m[i];
        edge[c[i]].push_back(t[i]);
    }
    dp[0][C] = 0;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j <= C; ++j){
            if(dp[i][j] >= MM) continue;
            for(auto e: edge[i]){
                if(j - Gcost[i][e] < 0) continue;
                dp[e][j - Gcost[i][e]] = min(dp[e][j - Gcost[i][e]], dp[i][j] + Gtime[i][e] );
            }
        }
    }
    ll ans = MM;
    for(int i = 0; i < C+1; ++i){
        ans = min(ans, dp[N-1][i]);
    }
    if(ans >= MM) cout << -1;
    else cout << ans;
    return 0;
}
0