結果

問題 No.1037 exhausted
ユーザー RhoRho
提出日時 2020-04-24 22:25:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 2,665 ms
コンパイル使用メモリ 181,036 KB
実行使用メモリ 35,020 KB
最終ジャッジ日時 2024-04-23 03:34:53
合計ジャッジ時間 3,121 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 26 ms
34,848 KB
testcase_13 AC 25 ms
35,004 KB
testcase_14 AC 26 ms
34,852 KB
testcase_15 AC 26 ms
34,996 KB
testcase_16 AC 25 ms
34,804 KB
testcase_17 AC 26 ms
34,852 KB
testcase_18 AC 26 ms
34,840 KB
testcase_19 AC 25 ms
34,948 KB
testcase_20 AC 20 ms
34,676 KB
testcase_21 AC 20 ms
34,960 KB
testcase_22 AC 20 ms
35,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)

int x[2005], v[2006], w[2005];
int dp[2005][2005];
signed main() {
	int n, V, l; cin >> n >> V >> l;
	rep(i, n)cin >> x[i+1] >> v[i] >> w[i];

	rep(i, n + 1)rep(j, V + 1)dp[i][j] = 1e17;
	dp[0][0] = 0;
	rep(i, n) {
		rep(j, V + 1) {
			if (dp[i][j] == 1e17)continue;
			if (x[i + 1] - x[i] + j <= V)dp[i + 1][j + x[i + 1] - x[i]] = min(dp[i + 1][j + x[i + 1] - x[i]], dp[i][j]);
		}
		rep(j, V + 1) {
			dp[i + 1][max(0ll, j - v[i])] = min(dp[i + 1][max(0ll, j - v[i])], dp[i + 1][j] + w[i]);
		}
	}
	int ans = 1e17;
	for(int i=0;i<=V-l+x[n];i++)ans = min(ans, dp[n][i]);
	if (ans == 1e17)ans = -1;
	cout << ans << endl;
}
0