結果
問題 | No.1 道のショートカット |
ユーザー | data9824 |
提出日時 | 2015-06-10 04:36:15 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,192 bytes |
コンパイル時間 | 2,845 ms |
コンパイル使用メモリ | 63,044 KB |
実行使用メモリ | 5,256 KB |
最終ジャッジ日時 | 2023-09-22 12:21:07 |
合計ジャッジ時間 | 3,816 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 3 ms
4,384 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 2 ms
4,380 KB |
testcase_16 | WA | - |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 1 ms
4,376 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 2 ms
4,380 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 1 ms
4,380 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 2 ms
4,380 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 1 ms
4,380 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 1 ms
4,380 KB |
testcase_43 | AC | 2 ms
4,376 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <limits> using namespace std; int n; int costs[51][51]; int times[51][51]; int scan(int city, int cost, int time) { if (city == n) { return time; } int minTime = numeric_limits<int>::max(); for (int next = city + 1; next <= n; ++next) { if (costs[city][next] != numeric_limits<int>::max()) { if (costs[city][next] <= cost) { minTime = min(minTime, scan(next, cost - costs[city][next], time + times[city][next])); } } } return minTime; } int main() { int c, v; cin >> n >> c >> v; vector<int> s(v); for (int i = 0; i < v; ++i) { cin >> s[i]; } vector<int> t(v); for (int i = 0; i < v; ++i) { cin >> t[i]; } vector<int> y(v); for (int i = 0; i < v; ++i) { cin >> y[i]; } vector<int> m(v); for (int i = 0; i < v; ++i) { cin >> m[i]; } fill(&costs[0][0], &costs[n][n] + 1, numeric_limits<int>::max()); fill(×[0][0], ×[n][n] + 1, numeric_limits<int>::max()); for (int i = 0; i < v; ++i) { costs[s[i]][t[i]] = y[i]; times[s[i]][t[i]] = m[i]; } int result = scan(1, c, 0); cout << ((result == numeric_limits<int>::max()) ? -1 : result) << endl; return 0; }