結果
| 問題 |
No.1037 exhausted
|
| コンテスト | |
| ユーザー |
kibuna
|
| 提出日時 | 2020-04-24 22:39:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,193 bytes |
| コンパイル時間 | 1,567 ms |
| コンパイル使用メモリ | 173,224 KB |
| 実行使用メモリ | 34,688 KB |
| 最終ジャッジ日時 | 2024-10-15 03:15:00 |
| 合計ジャッジ時間 | 2,737 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
return (b < a) ? (a = b, 1) : 0;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
lint n, V, L;
cin >> n >> V >> L;
vector<lint> x(n + 2), v(n + 2), w(n + 2);
for (int i = 1; i <= n; ++i) {
cin >> x[i] >> v[i] >> w[i];
}
x[n + 1] = L;
v[n + 1] = 0;
w[n + 1] = 0;
vector<vector<lint>> dp(n + 2, (vector<lint>(V + 1, inf)));
dp[0][V] = 0;
for (int i = 1; i <= n + 1; ++i) {
for (int j = 0; j <= V; ++j) {
if (j + (x[i] - x[i - 1]) <= V)
chmin(dp[i][j], dp[i - 1][j + (x[i] - x[i - 1])]);
}
for (int j = 0; j <= V; ++j) {
chmin(dp[i][min(V, j + v[i])], dp[i][j] + w[i]);
}
}
lint ret = inf;
for (int j = 0; j <= V; ++j) {
chmin(ret, dp[n + 1][j]);
}
if (ret == inf)
cout << -1 << "\n";
else
cout << ret << "\n";
return 0;
}
kibuna