結果
| 問題 | No.1 道のショートカット |
| コンテスト | |
| ユーザー |
Ysmr_Ry
|
| 提出日時 | 2014-12-12 09:59:41 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,059 bytes |
| 記録 | |
| コンパイル時間 | 440 ms |
| コンパイル使用メモリ | 72,264 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-03-29 19:42:45 |
| 合計ジャッジ時間 | 4,973 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 3 WA * 33 RE * 4 |
ソースコード
#include<cstdio>
#include<algorithm>
#include<limits>
#include<utility>
#include<vector>
#define rep(i,a) for(int i=0;i<(a);++i)
const int INF = std::numeric_limits<int>::max()>>2;
template<class T>
void chmin( T &a, T b )
{
if( a > b )
a = b;
return;
}
struct edge
{
int to, cost, tim;
edge( int to, int cost, int tim )
: to(to), cost(cost), tim(tim)
{}
};
int N, C, V;
std::vector<edge> G[50];
int S[50], T[50], Y[50], M[50];
int main()
{
scanf( "%d%d%d", &N, &C, &V );
rep( i, N )
scanf( "%d", S+i );
rep( i, N )
scanf( "%d", T+i );
rep( i, N )
scanf( "%d", Y+i );
rep( i, N )
scanf( "%d", M+i );
rep( i, N )
G[S[i]-1].push_back( edge( T[i]-1, Y[i], M[i] ) );
std::vector<std::vector<int> > dp( 50, std::vector<int>( C+1, INF ) );
rep( j, C+1 )
dp[0][j] = 0;
rep( i, N ) rep( k, C+1 ) rep( j, G[i].size() ) if( k+G[i][j].cost <= C )
chmin( dp[G[i][j].to][k+G[i][j].cost], dp[i][k]+G[i][j].tim );
printf( "%d\n", dp[N-1][C]==INF?-1:dp[N-1][C] );
return 0;
}
Ysmr_Ry