結果

問題 No.1037 exhausted
ユーザー recososorecososo
提出日時 2020-04-25 14:30:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 1,067 bytes
コンパイル時間 1,462 ms
コンパイル使用メモリ 168,576 KB
実行使用メモリ 34,688 KB
最終ジャッジ日時 2024-04-24 16:58:39
合計ジャッジ時間 2,626 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 35 ms
34,560 KB
testcase_13 AC 33 ms
34,432 KB
testcase_14 AC 33 ms
34,432 KB
testcase_15 AC 33 ms
34,560 KB
testcase_16 AC 32 ms
34,432 KB
testcase_17 AC 33 ms
34,432 KB
testcase_18 AC 33 ms
34,304 KB
testcase_19 AC 36 ms
34,432 KB
testcase_20 AC 29 ms
34,432 KB
testcase_21 AC 26 ms
34,688 KB
testcase_22 AC 27 ms
34,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,v,l;cin >> n >> v >> l;
    vector<vector<ll>> dp(n+1,vector<ll>(v+1,INF));
    dp[0][v]=0;
    vector<ll> x(n+1),u(n),w(n);
    for(int i=0;i<n;i++){
        cin >> x[i+1] >> u[i] >> w[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=v;j++){
            if(dp[i][j]==INF){
                continue;
            }
            if(j>=x[i+1]-x[i]){
                chmin(dp[i+1][j-(x[i+1]-x[i])],dp[i][j]);
                chmin(dp[i+1][min(v,j-(x[i+1]-x[i])+u[i])],dp[i][j]+w[i]);
            }
        }
    }
    ll ans=INF;
    for(int i=l-x[n];i<=v;i++){
        chmin(ans,dp[n][i]);
    }
    cout <<(ans==INF?-1:ans) << endl;
}
0