結果

問題 No.1037 exhausted
ユーザー petite_prog
提出日時 2020-04-24 22:14:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 2,710 bytes
コンパイル時間 1,580 ms
コンパイル使用メモリ 182,208 KB
実行使用メモリ 34,688 KB
最終ジャッジ日時 2024-10-15 02:59:47
合計ジャッジ時間 2,683 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

/*
   ∫ ∫ ∫
   
  _ 
 _   
______
 (´・ω・)ノ 
   |  /
   UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
const char bn = '\n';
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //使!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
int N = V.size();
REP(i,N){
os << V[i];
if (i!=N-1) os << " ";
}
os << "\n";
return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
os << "(";
os << P.first;
os << " , ";
os << P.second;
os << ")";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
auto it=S.begin();
while(it!=S.end()){
os << *it;
os << " ";
it++;
}
os << "\n";
return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
for(auto it=q.begin();it<q.end();it++){
os<<*it;
os<<" ";
}
os<<endl;
return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, map<T,S> const&M){
for(auto e:M){
os<<e;
}
os<<endl;
return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N,V,L;
cin >> N >> V >> L;
vector<tuple<int64,int64,int64>> XVW;
REP(i,N){
int64 x,v,w; cin >> x >> v >> w;
XVW.emplace_back(x,v,w);
}
vector<vector<int64>> DP(N+1,vector<int64>(V+1,INF));
DP[0][V] = 0;
int64 before_x = 0;
REP(i,N){
int64 x,v,w; tie(x,v,w) = XVW[i];
int64 dist = x-before_x;
REP(gas,V+1){
int remain = gas-dist;
if(remain<0) continue;
chmin(DP[i+1][remain], DP[i][gas]);
chmin(DP[i+1][min(int64(V),remain+v)], DP[i][gas] + w);
}
before_x = x;
}
int64 ans = INF;
for(int gas=L-before_x; gas<=V; gas++) chmin(ans, DP.back()[gas]);
if(ans==INF) cout << -1 << bn;
else cout << ans << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0