結果
問題 |
No.1037 exhausted
|
ユーザー |
![]() |
提出日時 | 2020-04-18 22:00:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,152 bytes |
コンパイル時間 | 2,937 ms |
コンパイル使用メモリ | 201,292 KB |
最終ジャッジ日時 | 2025-01-09 21:17:39 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 WA * 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}; } for(lint i=0;i<=n;i++){ if(V<std::get<0>(a.at(i+1))-std::get<0>(a.at(i))){ std::cout<<-1<<'\n'; return 0; } } 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-v;j>=0;j--){ if(dp.at(j)==inf)continue; cmn(dp.at(j+v),dp.at(j)+w); } } std::cout<<dp.at(0)<<'\n'; }