結果

問題 No.1037 exhausted
ユーザー kotatsugamekotatsugame
提出日時 2020-04-24 22:01:33
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 67,704 KB
実行使用メモリ 34,928 KB
最終ジャッジ日時 2023-08-05 04:58:58
合計ジャッジ時間 1,800 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 24 ms
34,536 KB
testcase_13 AC 24 ms
34,592 KB
testcase_14 AC 24 ms
34,516 KB
testcase_15 AC 24 ms
34,604 KB
testcase_16 AC 24 ms
34,528 KB
testcase_17 AC 24 ms
34,660 KB
testcase_18 AC 24 ms
34,628 KB
testcase_19 AC 23 ms
34,724 KB
testcase_20 AC 22 ms
34,532 KB
testcase_21 AC 21 ms
34,928 KB
testcase_22 AC 17 ms
34,616 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,V,L;
long dp[2001][2001];
main()
{
	cin>>N>>V>>L;
	for(int i=0;i<=V;i++)dp[0][i]=4e18;
	dp[0][V]=0;
	int pre=0;
	for(int i=0;i<N;i++)
	{
		for(int j=0;j<=V;j++)dp[i+1][j]=4e18;
		int x,v,w;cin>>x>>v>>w;
		for(int j=0;j<=V;j++)
		{
			if(j<x-pre)continue;
			int nj=j-(x-pre);
			dp[i+1][nj]=min(dp[i+1][nj],dp[i][j]);
			dp[i+1][min(V,nj+v)]=min(dp[i+1][min(V,nj+v)],dp[i][j]+w);
		}
		pre=x;
	}
	long ans=4e18;
	for(int j=0;j<=V;j++)
	{
		if(j<L-pre)continue;
		ans=min(ans,dp[N][j]);
	}
	cout<<(ans<1e18?ans:-1)<<endl;
}
0