結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-14 11:20:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,376 bytes |
| コンパイル時間 | 155 ms |
| コンパイル使用メモリ | 29,412 KB |
| 最終ジャッジ日時 | 2024-11-14 19:03:08 |
| 合計ジャッジ時間 | 632 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:3: error: ‘vector’ was not declared in this scope
15 | vector<int> s(v), t(v), y(v), m(v);
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:15:10: error: expected primary-expression before ‘int’
15 | vector<int> s(v), t(v), y(v), m(v);
| ^~~
main.cpp:16:40: error: ‘s’ was not declared in this scope
16 | for(int i : range(v)) { scanf("%d", &s[i]); }
| ^
main.cpp:17:40: error: ‘t’ was not declared in this scope
17 | for(int i : range(v)) { scanf("%d", &t[i]); }
| ^
main.cpp:18:40: error: ‘y’ was not declared in this scope
18 | for(int i : range(v)) { scanf("%d", &y[i]); }
| ^
main.cpp:19:40: error: ‘m’ was not declared in this scope
19 | for(int i : range(v)) { scanf("%d", &m[i]); }
| ^
main.cpp:21:5: error: ‘s’ was not declared in this scope
21 | s[i]--; t[i]--;
| ^
main.cpp:21:13: error: ‘t’ was not declared in this scope
21 | s[i]--; t[i]--;
| ^
main.cpp:23:32: error: ‘y’ was not declared in this scope
23 | yen [s[i]][route[s[i]]] = y[i];
| ^
main.cpp:24:32: error: ‘m’ was not declared in this scope
24 | mIn [s[i]][route[s[i]]] = m[i];
| ^
main.cpp:14:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | int n, c, v; scanf("%d%d%d", &n, &c, &v);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <algorithm>
using namespace std;
class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};
const int inf = 19921223;
int dp[55][333];
int route[55];
int yen[55][1555], mIn[55][1555], graph[55][1555];
int main(void) {
int n, c, v; scanf("%d%d%d", &n, &c, &v);
vector<int> s(v), t(v), y(v), m(v);
for(int i : range(v)) { scanf("%d", &s[i]); }
for(int i : range(v)) { scanf("%d", &t[i]); }
for(int i : range(v)) { scanf("%d", &y[i]); }
for(int i : range(v)) { scanf("%d", &m[i]); }
for(int i : range(v)) {
s[i]--; t[i]--;
graph[s[i]][route[s[i]]] = t[i];
yen [s[i]][route[s[i]]] = y[i];
mIn [s[i]][route[s[i]]] = m[i];
route[s[i]]++;
}
for(int i : range(n+1)) {
for(int j : range(c+1)) {
dp[i][j] = i==0? 0 : inf;
}
}
for(int i : range(n)) {
for(int k : range(c+1)) {
if(dp[i][k] == inf) { continue; }
for(int j : range(route[i])) {
int kk = k + yen[i][j];
if(kk > c) { continue; }
dp[graph[i][j]][kk] = min(dp[graph[i][j]][kk], dp[i][k] + mIn[i][j]);
}
}
}
int res = dp[n-1][c];
if(res == inf) { res = -1; }
printf("%d\n", res);
return 0;
}