結果
| 問題 | No.1037 exhausted |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-24 22:07:36 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 2,000 ms |
| コード長 | 795 bytes |
| 記録 | |
| コンパイル時間 | 1,296 ms |
| コンパイル使用メモリ | 210,672 KB |
| 実行使用メモリ | 74,240 KB |
| 最終ジャッジ日時 | 2026-06-09 17:27:27 |
| 合計ジャッジ時間 | 3,361 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef long long ll;
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll dp[3000][3000];
ll x[3000],v[3000],w[3000];
int main(){
ll n,V,L;cin>>n>>V>>L;
rep(i,n){
scanf("%lld%lld%lld",&x[i],&v[i],&w[i]);
}
x[n]=L;
if(V<x[0]){
puts("-1");return 0;
}
memset(dp,0x3f,sizeof(dp));
dp[0][V-x[0]]=0;
rep(i,n)rep(j,V+1){
if(dp[i][j]==INFL)continue;
ll cost=x[i+1]-x[i];
if(j>=cost)dp[i+1][j-cost]=min(dp[i+1][j-cost],dp[i][j]);
if(int nj=min(V,j+v[i]);nj>=cost)dp[i+1][nj-cost]=min(dp[i+1][nj-cost],dp[i][j]+w[i]);
}
ll Min=INFL;
for(int i=0;i<=V;i++){
Min=min(Min,dp[n][i]);
}
if(Min==INFL)puts("-1");
else cout<<Min<<endl;
}