結果
問題 | No.1037 exhausted |
ユーザー |
|
提出日時 | 2020-04-25 02:02:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 857 bytes |
コンパイル時間 | 1,947 ms |
コンパイル使用メモリ | 171,220 KB |
実行使用メモリ | 34,560 KB |
最終ジャッジ日時 | 2024-10-15 13:42:26 |
合計ジャッジ時間 | 3,294 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;constexpr ll INF = 1e17;int main() {cin.tie(nullptr);ios::sync_with_stdio(false);int n, V, L;cin >> n >> V >> L;vector< vector<ll> > dp(n + 1, vector<ll>(V + 1, INF));dp[0][V] = 0;int prvx = 0;for (int i = 0; i < n; ++i) {int x, v;ll w;cin >> x >> v >> w;int hoge = x - prvx;for (int j = hoge; j <= V; ++j) {dp[i + 1][j - hoge] = min(dp[i + 1][j - hoge], dp[i][j]);ll& tar = dp[i + 1][min(j - hoge + v, V)];tar = min(tar, dp[i][j] + w);}prvx = x;}ll foo = L - prvx;ll ans = INF;for (ll i = foo; i <= V; ++i) {ans = min(ans, dp[n][i]);}cout << (ans >= INF ? -1 : ans) << "\n";return 0;}