結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
tkmst201
|
| 提出日時 | 2017-05-14 22:11:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 5,000 ms |
| コード長 | 1,192 bytes |
| コンパイル時間 | 1,289 ms |
| コンパイル使用メモリ | 158,564 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 16:29:36 |
| 合計ジャッジ時間 | 2,420 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | REP(i, v) { scanf("%d", s + i); s[i]--; }
| ~~~~~^~~~~~~~~~~~~
main.cpp:29:26: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | REP(i, v) { scanf("%d", t + i); t[i]--; }
| ~~~~~^~~~~~~~~~~~~
main.cpp:30:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | REP(i, v) scanf("%d", y + i);
| ~~~~~^~~~~~~~~~~~~
main.cpp:31:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
31 | REP(i, v) scanf("%d", m + i);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
int n, c, v;
int s[1500], t[1500], y[1500], m[1500];
int dp[301][50];
int main() {
cin >> n >> c >> v;
REP(i, v) { scanf("%d", s + i); s[i]--; }
REP(i, v) { scanf("%d", t + i); t[i]--; }
REP(i, v) scanf("%d", y + i);
REP(i, v) scanf("%d", m + i);
fill(dp[0], dp[c + 1], INF);
dp[0][0] = 0;
REP(i, c + 1) REP(j, n) {
if (dp[i][j] == INF) continue;
REP(k, v) if (s[k] == j) {
if (i + y[k] > c) continue;
chmin(dp[i + y[k]][t[k]], dp[i][j] + m[k]);
}
}
int ans = INF;
REP(i, c + 1) chmin(ans, dp[i][n - 1]);
if (ans == INF) puts("-1");
else cout << ans << endl;
return 0;
}
tkmst201