結果
問題 | No.1 道のショートカット |
ユーザー | matsu7874 |
提出日時 | 2015-12-07 22:21:04 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 1,184 bytes |
コンパイル時間 | 1,300 ms |
コンパイル使用メモリ | 161,884 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-20 16:18:36 |
合計ジャッジ時間 | 2,304 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 0 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 3 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 1 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | AC | 1 ms
5,376 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | AC | 1 ms
5,376 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
testcase_38 | AC | 1 ms
5,376 KB |
testcase_39 | AC | 1 ms
5,376 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 1 ms
5,376 KB |
testcase_43 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:16:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:17:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | scanf("%d", &C); | ~~~~~^~~~~~~~~~ main.cpp:18:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d", &V); | ~~~~~^~~~~~~~~~ main.cpp:21:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d", &S[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:25:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d", &T[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:29:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%d", &Y[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:33:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%d", &M[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define ALL(c) c.begin(), c.end() #define REP(i, n) \ for (int i = 0; i < (int)(n); ++i) #define FOR(i, l, r) \ for (int i = (int)(l); i < (int)(r); ++i) #define EACH(it, o) \ for (auto it = (o).begin(); it != (o).end(); ++it) #define INF (1 << 26) using namespace std; int main() { int N, C, V; scanf("%d", &N); scanf("%d", &C); scanf("%d", &V); int S[V], T[V], Y[V], M[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]); } int p[V]; REP(i, V) { p[i] = i; } sort(p, p + V, [&](int a, int b) { return S[a] < S[b]; }); long dp[N + 1][C + 1]; REP(i, N + 1) { REP(j, C + 1) { dp[i][j] = INF; } } dp[1][C] = 0; REP(i, V) { int ptr = p[i]; REP(j, C+1) { if (Y[ptr] + j <= C) { dp[T[ptr]][j] = min(dp[T[ptr]][j], dp[S[ptr]][j + Y[ptr]] + M[ptr]); } } } long min_time = INF; REP(i, C+1) { min_time = min(min_time, dp[N][i]); } if (min_time == INF) { printf("-1\n"); } else { printf("%ld\n", min_time); } return 0; }