結果
| 問題 | No.1037 exhausted |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-24 22:01:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 589 bytes |
| コンパイル時間 | 523 ms |
| コンパイル使用メモリ | 68,432 KB |
| 実行使用メモリ | 34,716 KB |
| 最終ジャッジ日時 | 2024-10-15 02:50:43 |
| 合計ジャッジ時間 | 1,490 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main()
| ^~~~
ソースコード
#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;
}