結果
| 問題 |
No.1037 exhausted
|
| コンテスト | |
| ユーザー |
imoni_kawaii
|
| 提出日時 | 2020-06-09 22:04:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 2,000 ms |
| コード長 | 1,057 bytes |
| コンパイル時間 | 2,499 ms |
| コンパイル使用メモリ | 192,372 KB |
| 最終ジャッジ日時 | 2025-01-11 00:34:23 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }
int N, V, L, x[2010], v[2010], w[2010];
ll dp[2010][2010];
int main() {
cin.tie(0); ios::sync_with_stdio(false);
cin >> N >> V >> L;
REP(i, 1, N+1) cin >> x[i] >> v[i] >> w[i];
x[0] = w[0] = 0;
v[0] = V;
x[N+1] = L;
rep(i, 2010) rep(j, 2010) dp[i][j] = (1LL<<60);
dp[0][0] = 0;
rep(i, N+1) rep(j, V+1) {
if(min(V, j+v[i])-(x[i+1]-x[i]) >= 0) chmin(dp[i+1][min(V, j+v[i])-(x[i+1]-x[i])], dp[i][j]+w[i]);
if(j-(x[i+1]-x[i]) >= 0) chmin(dp[i+1][j-(x[i+1]-x[i])], dp[i][j]);
}
ll ans = (1LL<<60);
rep(j, V+1) {
chmin(ans, dp[N+1][j]);
}
if(ans == (1LL<<60)) ans = -1;
cout << ans << '\n';
return 0;
}
imoni_kawaii