結果
問題 |
No.1037 exhausted
|
ユーザー |
![]() |
提出日時 | 2020-04-18 22:05:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,064 bytes |
コンパイル時間 | 2,117 ms |
コンパイル使用メモリ | 201,104 KB |
最終ジャッジ日時 | 2025-01-09 21:17:50 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 RE * 5 |
ソースコード
#include<bits/stdc++.h> #define ALL(v) std::begin(v),std::end(v) using lint=long long; using ld=long double; template<class T>using numr=std::numeric_limits<T>; void cmn(lint&x,lint y){if(x>y)x=y;} int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint inf=numr<lint>::max(); lint n,V,L;std::cin>>n>>V>>L; std::vector<std::tuple<lint,lint,lint>>a(n+2); a.at(0)={0,0,0},a.at(n+1)={L,0,0}; for(lint i=1;i<=n;i++){ lint x,v,w;std::cin>>x>>v>>w; a.at(i)={x,v,w}; } std::vector<lint>dp(V+1,0); for(lint i=1;i<=n+1;i++){ lint x,v,w;std::tie(x,v,w)=a.at(i); x-=std::get<0>(a.at(i-1)); std::copy(dp.begin()+x,dp.end(),dp.begin()); std::fill(dp.end()-x,dp.end(),inf); for(lint j=V;j>0;j--){ if(j<V)cmn(dp.at(j),dp.at(j+1)); if(v<=j&&dp.at(j-v)!=inf)cmn(dp.at(j),dp.at(j-v)+w); } } lint ans=dp.at(0); if(ans==inf)ans=-1; std::cout<<ans<<'\n'; }