結果
問題 | No.1037 exhausted |
ユーザー |
![]() |
提出日時 | 2020-04-18 22:28:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 792 bytes |
コンパイル時間 | 1,997 ms |
コンパイル使用メモリ | 195,344 KB |
最終ジャッジ日時 | 2025-01-09 21:18:39 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
main.cpp:2:10: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’ 2 | void cmn(auto&x,auto y){if(x>y)x=y;} | ^~~~ main.cpp:2:17: warning: use of ‘auto’ in parameter declaration only available with ‘-std=c++20’ or ‘-fconcepts’ 2 | void cmn(auto&x,auto y){if(x>y)x=y;} | ^~~~
ソースコード
#include<bits/stdc++.h>void cmn(auto&x,auto y){if(x>y)x=y;}auto min_fn=[](auto&&x,auto&&y){return std::min(x,y);};int main(){int inf=std::numeric_limits<int>::max();int n,V,L;std::cin>>n>>V>>L;std::vector<int>x(n+2),v(n+2),w(n+2);x[n+1]=L;for(int i=1;i<=n;i++)std::cin>>x[i]>>v[i]>>w[i];std::vector<int>dp(V+1,0);for(int i=1;i<=n+1;i++){int d=std::min(V+1,x[i]-x[i-1]);std::copy(dp.begin()+std::min(d,V+1),dp.end(),dp.begin());std::fill(dp.end()-std::min(d,V+1),dp.end(),inf);for(int j=V-v[i];j>=0;j--){if(inf-w[i]<=dp[j])continue;cmn(dp.at(j+v[i]),dp[j]+w[i]);}std::partial_sum(dp.rbegin(),dp.rend(),dp.rbegin(),min_fn);}std::cout<<(dp[0]==inf?-1:dp[0])<<'\n';}