結果

問題 No.1 道のショートカット
ユーザー BantakoBantako
提出日時 2018-06-07 20:29:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 5,000 ms
コード長 1,285 bytes
コンパイル時間 1,964 ms
コンパイル使用メモリ 178,572 KB
実行使用メモリ 93,580 KB
最終ジャッジ日時 2023-09-27 22:14:49
合計ジャッジ時間 3,210 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 37 ms
74,620 KB
testcase_09 AC 18 ms
39,124 KB
testcase_10 AC 10 ms
22,084 KB
testcase_11 AC 11 ms
25,508 KB
testcase_12 AC 43 ms
93,580 KB
testcase_13 AC 46 ms
93,504 KB
testcase_14 AC 4 ms
5,484 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 7 ms
14,444 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 3 ms
6,212 KB
testcase_19 AC 3 ms
7,476 KB
testcase_20 AC 5 ms
10,240 KB
testcase_21 AC 4 ms
9,596 KB
testcase_22 AC 4 ms
5,920 KB
testcase_23 AC 10 ms
21,864 KB
testcase_24 AC 10 ms
24,840 KB
testcase_25 AC 5 ms
11,408 KB
testcase_26 AC 4 ms
7,516 KB
testcase_27 AC 17 ms
38,104 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 6 ms
9,112 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 3 ms
4,700 KB
testcase_32 AC 20 ms
42,272 KB
testcase_33 AC 11 ms
27,296 KB
testcase_34 AC 12 ms
28,052 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 7 ms
11,180 KB
testcase_37 AC 3 ms
4,380 KB
testcase_38 AC 2 ms
4,568 KB
testcase_39 AC 6 ms
11,200 KB
testcase_40 AC 3 ms
5,360 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef tuple<int,int,int,int> Tp;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,C,V;
    cin >> N >> C >> V;
    vector< Tp > Vec;
    vector<int> S(V*4),T(N),Y(N),M(N);
    rep(i,0,V*4)cin >> S[i];
    rep(i,0,V){
        Vec.emplace_back(S[i], S[i+V], S[i+V*2], S[i+V*3]);
    }
    sort(Vec.begin(), Vec.end());
    int dp[V+1][N+1][C+1];
    rep(i,0,V+1)rep(j,0,N+1)rep(k,0,C+1)dp[i][j][k] = INF;
    dp[0][0][0] = 0;

    /*          
    rep(i,0,V){
        int s = get<0>(Vec[i])-1,t = get<1>(Vec[i])-1,y = get<2>(Vec[i]),m = get<3>(Vec[i]);
        cout << s << " " << t << " " << y << " " << m << endl;
    }
                  */


    rep(i,0,V){
        int s = get<0>(Vec[i])-1,t = get<1>(Vec[i])-1,y = get<2>(Vec[i]),m = get<3>(Vec[i]);
        rep(j,0,N+1)rep(k,0,C+1)dp[i+1][j][k] = dp[i][j][k];
        rep(j,0,C+1){
            //dp[i+1][t][j] = min(dp[i][t][j], dp[i+1][t][j]);
            if(j + y <= C){
                dp[i+1][t][j+y] = min(dp[i][t][j+y], dp[i][s][j] + m);
            }
        }
    }
    int mini = INF;
    rep(i,0,C+1)mini = min(mini, dp[V][N-1][i]);
    if(mini == INF)mini = -1;
    cout << mini << endl;
}
0