結果
| 問題 | No.1 道のショートカット |
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-09-10 18:16:26 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 892 bytes |
| 記録 | |
| コンパイル時間 | 308 ms |
| コンパイル使用メモリ | 66,720 KB |
| 最終ジャッジ日時 | 2026-04-03 01:23:14 |
| 合計ジャッジ時間 | 745 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:24:36: error: 'INT32_MAX' was not declared in this scope
24 | DP[i][j] = INT32_MAX;
| ^~~~~~~~~
main.cpp:4:1: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
3 | #include <algorithm>
+++ |+#include <cstdint>
4 | using namespace std;
main.cpp:32:41: error: 'INT32_MAX' was not declared in this scope
32 | if (DP[i][j] == INT32_MAX) continue;
| ^~~~~~~~~
main.cpp:32:41: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
main.cpp:43:18: error: 'INT32_MAX' was not declared in this scope
43 | int mn = INT32_MAX;
| ^~~~~~~~~
main.cpp:43:18: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MAX_N 51
int N, C, V;
int DP[301][51];
int main()
{
cin >> N >> C >> V;
vector<int> S(V), T(V), Y(V), M(V);
rep(i, V)cin >> S[i];
rep(i, V)cin >> T[i];
rep(i, V)cin >> Y[i];
rep(i, V)cin >> M[i];
for (int i = 0; i <= C ; i++) {
for (int j = 1; j <= N; j++) {
DP[i][j] = INT32_MAX;
}
}
DP[C][1] = 0;
for (int i = C; i >=0; i--) {
for (int j = 1; j <= N; j++) {
if (DP[i][j] == INT32_MAX) continue;
for (int k = 0; k < V; k++) {
if (j == S[k]) {
if (i - Y[k] < 0)continue;
DP[i - Y[k]][T[k]] = min(DP[i - Y[k]][T[k]], DP[i][j] + M[k]);
}
}
}
}
int mn = INT32_MAX;
for (int i = 0; i <= C; i++) {
mn = min(mn, DP[i][N]);
}
if (mn == INT32_MAX)cout << -1 << endl;
else cout << mn << endl;
return 0;
}
kurenai3110