結果

問題 No.1037 exhausted
ユーザー tko919tko919
提出日時 2020-04-27 18:15:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 973 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 169,744 KB
実行使用メモリ 35,340 KB
最終ジャッジ日時 2024-05-01 19:40:17
合計ジャッジ時間 2,800 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 10 ms
35,232 KB
testcase_03 AC 11 ms
35,120 KB
testcase_04 AC 10 ms
35,276 KB
testcase_05 AC 10 ms
35,156 KB
testcase_06 WA -
testcase_07 AC 10 ms
35,096 KB
testcase_08 WA -
testcase_09 AC 10 ms
35,204 KB
testcase_10 AC 10 ms
35,204 KB
testcase_11 WA -
testcase_12 AC 25 ms
35,240 KB
testcase_13 AC 25 ms
35,128 KB
testcase_14 AC 26 ms
35,168 KB
testcase_15 AC 24 ms
35,224 KB
testcase_16 AC 26 ms
35,144 KB
testcase_17 AC 26 ms
35,172 KB
testcase_18 AC 27 ms
35,168 KB
testcase_19 AC 27 ms
35,240 KB
testcase_20 AC 18 ms
35,236 KB
testcase_21 AC 18 ms
35,172 KB
testcase_22 AC 16 ms
35,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

ll dp[2010][2010];

int main(){
   int n,v,l; scanf("%d%d%d",&n,&v,&l);
   vector<int> x(n+1),y(n),z(n); x[n]=l;
   rep(i,0,n)scanf("%d%d%d",&x[i],&y[i],&z[i]);
   rep(i,0,2010)rep(j,0,2010)dp[i][j]=INF; dp[0][v]=0;
   rep(i,0,n)rep(j,0,v+1)if(dp[i][j]!=INF){
      if(j-x[i+1]+x[i]>=0)chmin(dp[i+1][j-x[i+1]+x[i]],dp[i][j]);
      if(min(v,j+y[i])-x[i+1]+x[i]>=0)chmin(dp[i+1][min(v,j+y[i])-x[i+1]+x[i]],dp[i][j]+z[i]);
   }
   ll res=INF;
   rep(i,0,v+1)chmin(res,dp[n][i]);
   printf(res==INF?"-1\n":"%lld\n",res);
   return 0;
}
0