結果

問題 No.1037 exhausted
ユーザー ace_amuroace_amuro
提出日時 2024-04-03 16:30:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,028 bytes
コンパイル時間 851 ms
コンパイル使用メモリ 82,880 KB
実行使用メモリ 19,452 KB
最終ジャッジ日時 2024-04-03 16:30:10
合計ジャッジ時間 2,217 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
19,440 KB
testcase_01 AC 6 ms
19,440 KB
testcase_02 WA -
testcase_03 AC 6 ms
19,440 KB
testcase_04 WA -
testcase_05 AC 6 ms
19,440 KB
testcase_06 AC 6 ms
19,440 KB
testcase_07 WA -
testcase_08 AC 6 ms
19,440 KB
testcase_09 AC 6 ms
19,440 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 18 ms
19,452 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 18 ms
19,452 KB
testcase_21 AC 17 ms
19,452 KB
testcase_22 AC 14 ms
19,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int MR=2e3+10;
int n,V,L;
int x[MR],v[MR],w[MR];
int dp[MR][MR];
//dp[i][j]是到加油站i且油量剩j时的最少花费
int main(){
    cin>>n>>V>>L;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>v[i]>>w[i];
    }
    x[n+1]=L;
    memset(dp,0x3f,sizeof(dp));
    dp[0][V]=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=V;j++){
            int t=x[i+1]-x[i];
            //不加油直接出发,到下个站要消耗t
            if(j>=t) dp[i+1][j-t]=min(dp[i+1][j-t],dp[i][j]);
            //加油后出发,到下个站剩余 min(j+v[i],V)-t
            if(min(j+v[i],V)>=t){
                dp[i+1][min(j+v[i],V)-t]=min(dp[i+1][min(j+v[i],V)-t],dp[i][j]+w[i]);
            }
        }
    }
    if(dp[n+1][0]<1e9) cout<<dp[n+1][0]<<endl;
    else cout<<-1<<endl;
    return 0;
}
0