結果
| 問題 |
No.1037 exhausted
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-05 16:59:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 934 bytes |
| コンパイル時間 | 2,080 ms |
| コンパイル使用メモリ | 199,212 KB |
| 最終ジャッジ日時 | 2025-02-09 23:19:16 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 3 RE * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, V, L;
cin >> N >> V >> L;
struct {
int x;
int v;
int w;
} a[N+2];
for (int i = 1; i <= N; i++) {
cin >> a[i].x >> a[i].v >> a[i].w;
}
a[0].x = 0; a[N+1].x = L;
vector<vector<int>> dp(N+2, vector<int>(V+1, 1 << 30));
dp[0][V] = 0;
for (int i = 0; i < N+2; i++) {
for (int j = 0; j <= V; j++) {
if (dp[i][j] != 1 << 30 && a[i+1].x - a[i].x <= j) {
dp[i+1][min(V, j-a[i+1].x+a[i].x+a[i+1].v)] =
min(dp[i+1][min(V, j-a[i+1].x+a[i].x+a[i+1].v)], dp[i][j] + a[i+1].w);
dp[i+1][j-a[i+1].x+a[i].x] =
min(dp[i+1][j-a[i+1].x+a[i].x], dp[i][j]);
}
}
}
int ans = 1 << 30;
for (int i = 0; i <= V; i++) ans = min(ans, dp[N+1][i]);
if (ans == 1 << 30) ans = -1;
cout << ans << endl;
}