結果
問題 | No.1 道のショートカット |
ユーザー |
![]() |
提出日時 | 2015-02-17 23:42:17 |
言語 | C++11 (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,391 bytes |
コンパイル時間 | 816 ms |
コンパイル使用メモリ | 86,260 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-08 03:47:17 |
合計ジャッジ時間 | 7,517 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 RE * 1 |
other | AC * 7 RE * 33 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:38:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | FOR(i,V) scanf("%d",&S[i]); | ~~~~~^~~~~~~~~~~~ main.cpp:39:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 39 | FOR(i,V) scanf("%d",&T[i]); | ~~~~~^~~~~~~~~~~~ main.cpp:40:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 40 | FOR(i,V) scanf("%d",&Y[i]); | ~~~~~^~~~~~~~~~~~ main.cpp:41:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 41 | FOR(i,V) scanf("%d",&M[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<iostream> #include<sstream> #include<cstdio> #include<cstring> #include<algorithm> #include<string> #include<vector> #include<cmath> #include<set> #include<map> #include<stack> #include<queue> #include<numeric> #include<functional> #include<complex> using namespace std; #define BET(a,b,c) ((a)<=(b)&&(b)<(c)) #define FOR(i,n) for(int i=0,i##_end=(int(n));i<i##_end;i++) #define SZ(x) (int)(x.size()) #define ALL(x) (x).begin(),(x).end() #define MP make_pair #define FOR_EACH(it,v) for(__typeof(v.begin()) it=v.begin(),it_end=v.end() ; it != it_end ; it++) typedef vector<int> VI; typedef vector<VI> VVI; int dp[50][301]; void updateMin(int&v, int x){ if(v > x) v = x; } int main() { int N,C,V; cin>>N>>C>>V; VI S(N),T(N),Y(N),M(N); FOR(i,V) scanf("%d",&S[i]); FOR(i,V) scanf("%d",&T[i]); FOR(i,V) scanf("%d",&Y[i]); FOR(i,V) scanf("%d",&M[i]); FOR(i,V) { S[i]--; T[i]--; } const int inf = 1<<29; FOR(i,N) FOR(j,C+1) dp[i][j] = inf; dp[0][0] = 0; FOR(i,N){ FOR(j,V){ if(S[j] != i) continue; for(int c=C;c>=0;c--){ if(c + Y[j] <= C){ updateMin(dp[T[j]][c+Y[j]], dp[S[j]][c] + M[j]); } } } } int ans = inf; FOR(i,C+1) ans = min(ans, dp[N-1][i]); if(ans >= inf) ans = -1; cout<<ans<<endl; return 0; }