結果
問題 | No.1 道のショートカット |
ユーザー |
|
提出日時 | 2018-02-10 22:18:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,295 bytes |
コンパイル時間 | 809 ms |
コンパイル使用メモリ | 80,168 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-08 04:59:22 |
合計ジャッジ時間 | 4,564 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 RE * 1 |
other | AC * 14 WA * 4 RE * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d", &s[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%d", &t[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:29:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%d", &y[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:31:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | scanf("%d", &m[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <algorithm> #include <math.h> #include <vector> #include <queue> #include <map> #include <utility> using namespace std; #define INF 1000000000 int main(void) { int n, c, v; cin >> n >> c >> v; vector<int> s(v), t(v), y(v), m(v); pair<int, int> p1, p2; map<pair<int, int>, pair<int, int> > mp; vector<vector<int> > arr(n, vector<int>(0)); for (int i = 0; i < v; i++) scanf("%d", &s[i]); for (int i = 0; i < v; i++) scanf("%d", &t[i]); for (int i = 0; i < v; i++) scanf("%d", &y[i]); for (int i = 0; i < v; i++) scanf("%d", &m[i]); vector<vector<int> > time(n+1, vector<int>(c+1, INF)); time[1][c] = 0; for (int i = 1; i <= n; i++) for (int j = c; j >= 0; j--) { if (time[i][j] != INF) { for(int k = 0; k < v; k++) if(s[k]==i && time[i][j]+m[k]<time[t[k]][j-y[k]]) { time[t[k]][j-y[k]] = time[i][j] + m[k]; } } } int min = INF; for(int i = 0; i <= c; i++) if(min > time[n][i]) min = time[n][i]; cout << (min==INF?-1:min) << endl; return 0; }