結果

問題 No.1037 exhausted
ユーザー kotatsugamekotatsugame
提出日時 2020-04-24 22:01:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 69,640 KB
実行使用メモリ 34,840 KB
最終ジャッジ日時 2024-04-23 03:17:56
合計ジャッジ時間 1,593 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 27 ms
34,828 KB
testcase_13 AC 25 ms
34,840 KB
testcase_14 AC 24 ms
34,752 KB
testcase_15 AC 25 ms
34,836 KB
testcase_16 AC 25 ms
34,812 KB
testcase_17 AC 25 ms
34,788 KB
testcase_18 AC 24 ms
34,640 KB
testcase_19 AC 24 ms
34,732 KB
testcase_20 AC 22 ms
34,744 KB
testcase_21 AC 20 ms
34,704 KB
testcase_22 AC 16 ms
34,816 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-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