結果

問題 No.1 道のショートカット
ユーザー kzyKTkzyKT
提出日時 2016-05-23 19:54:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,842 bytes
コンパイル時間 4,407 ms
コンパイル使用メモリ 152,780 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 12:43:36
合計ジャッジ時間 3,545 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 5 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 2 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 3 ms
4,380 KB
testcase_30 WA -
testcase_31 AC 2 ms
4,380 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 2 ms
4,376 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,380 KB
testcase_43 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<int,P> PP;

void Main() {
  int n,c,m;
  cin >> n >> c >> m;
  int x[m],y[m],a[m],b[m];
  rep(i,m) R x[i],x[i]--;
  rep(i,m) R y[i],y[i]--;
  rep(i,m) R a[i];
  rep(i,m) R b[i];
  vector<PP> v[n];
  rep(i,m) v[x[i]].pb(PP(y[i],P(a[i],b[i])));
  priority_queue<PP,vector<PP>,greater<PP> > que;
  que.push(PP(0,P(0,0)));
  int d[n][c+1];
  rep(i,n)rep(j,c+1)d[i][j]=MAX;
  d[0][0]=0;
  while(!que.empty()) {
    PP p=que.top();que.pop();
    int x=p.S.F,cc=p.F,t=p.S.S;
    if(d[x][cc]<t) continue;
    rep(i,v[x].size()) {
      PP q=v[x][i];
      int y=q.F,c2=q.S.F,tt=q.S.S;
      if(c2+cc<=c&&d[y][c2+cc]>t+tt) {
        d[y][c2+cc]=t+tt;
        que.push(PP(t+tt,P(y,c2+cc)));
      }
    }
  }
  int ans=MAX;
  rep(i,c+1) ans=min(ans,d[n-1][i]);
  if(ans==MAX) ans=-1;
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}
0