結果

問題 No.1 道のショートカット
ユーザー itezpaceitezpace
提出日時 2016-09-03 12:02:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,226 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 66,228 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-22 12:49:39
合計ジャッジ時間 2,754 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <climits>
using namespace std;
int main(){
  int n,c,v;
  cin>>n;
  cin>>c;
  cin>>v;
  vector<vector<int>> vv;
  int n2=0;
  for(int i=0; i<4; ++i){
    vector<int> v1;
    for(int j=0; j<v; ++j){
      int a;
      cin>>a;
      v1.push_back(a);
      if(i==0){
        if(n2<a) n2=a;
      }
    }
    vv.push_back(v1);
  }
  int dp[c+1][n];
  for(int i=0; i<c+1; ++i){
    for(int j=0; j<n; ++j){
      if(j==0) dp[i][j]=0;
      else dp[i][j]=SHRT_MAX;
    }
  }
  for(int i=1; i<=n2; ++i){
    for(int j=0; j<v; ++j){
      int d=vv[0][j]; //1st
      if(i==d){
        for(int k=0; k<c+1; ++k){
          int e=dp[k][d-1]; //cost before
          int e2=e+vv[2][j]; //cost after
          if(e2<=c){
            int f=dp[e][d-1]; //time before
            int g=f+vv[3][j]; //time after
            int h=vv[1][j]; //2nd
            for(int l=d-1; l<h; ++l){
              int o=dp[e2][l];
              if(o>g){
                dp[e2][l]=g;
              }
            } //l
          }
        } //k
      }
    } //j
  } //l
  int z=SHRT_MAX;
  for(int i=0; i<c+1; ++i){
    int x=dp[i][n-1];
    if(z>x) z=x;
  }
  if(z==SHRT_MAX) z=-1;
  cout<<z<<endl;
  return 0;
}
0