結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
Ysmr_Ry
|
| 提出日時 | 2014-12-12 10:12:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,078 bytes |
| コンパイル時間 | 387 ms |
| コンパイル使用メモリ | 48,740 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 16:07:47 |
| 合計ジャッジ時間 | 1,430 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf( "%d%d%d", &N, &C, &V );
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:31:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | scanf( "%d", S+i );
| ~~~~~^~~~~~~~~~~~~
main.cpp:33:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf( "%d", T+i );
| ~~~~~^~~~~~~~~~~~~
main.cpp:35:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf( "%d", Y+i );
| ~~~~~^~~~~~~~~~~~~
main.cpp:37:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
37 | scanf( "%d", M+i );
| ~~~~~^~~~~~~~~~~~~
ソースコード
#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();
template<class T>
void chmin( T &a, T b )
{ a = std::min( 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[1500], T[1500], Y[1500], M[1500];
int main()
{
scanf( "%d%d%d", &N, &C, &V );
rep( i, V )
scanf( "%d", S+i );
rep( i, V )
scanf( "%d", T+i );
rep( i, V )
scanf( "%d", Y+i );
rep( i, V )
scanf( "%d", M+i );
rep( i, V )
G[S[i]-1].push_back( edge( T[i]-1, Y[i], M[i] ) );
std::vector<std::vector<int> > dp( N, std::vector<int>( C+1, INF ) );
rep( j, C+1 )
dp[0][j] = 0;
rep( i, N ) rep( k, C+1 ) if( dp[i][k] != INF ) 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