結果

問題 No.1037 exhausted
ユーザー kibunakibuna
提出日時 2020-04-24 22:39:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,193 bytes
コンパイル時間 1,666 ms
コンパイル使用メモリ 170,152 KB
実行使用メモリ 34,688 KB
最終ジャッジ日時 2024-04-23 03:42:23
合計ジャッジ時間 2,694 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,944 KB
testcase_09 WA -
testcase_10 AC 1 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 38 ms
34,560 KB
testcase_13 AC 37 ms
34,432 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 37 ms
34,560 KB
testcase_17 AC 37 ms
34,560 KB
testcase_18 AC 36 ms
34,560 KB
testcase_19 WA -
testcase_20 AC 37 ms
34,432 KB
testcase_21 AC 37 ms
34,432 KB
testcase_22 AC 34 ms
34,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0