제출 #1016846

#제출 시각아이디문제언어결과실행 시간메모리
101684612345678추월 (IOI23_overtaking)C++17
65 / 100
3562 ms67928 KiB
#include "overtaking.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int nx=1e3+5; ll n, m, e[nx][nx], t[nx][nx], sz, x; vector<ll> l, w, s; vector<pair<ll, ll>> dp[nx]; void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S) { n=N, m=M, x=X; s.resize(m); for (int i=0; i<n; i++) if (W[i]>X) l.push_back(T[i]), w.push_back(W[i]); for (int i=0; i<m; i++) s[i]=S[i]; sz=l.size(); for (int i=0; i<sz; i++) t[0][i]=l[i]; for (int i=1; i<m; i++) { vector<pair<ll, pair<ll, ll>>> v; for (int j=0; j<sz; j++) e[i][j]=t[i-1][j]+(s[i]-s[i-1])*w[j], v.push_back({t[i-1][j], {e[i][j], j}}); sort(v.begin(), v.end()); ll mx=0; for (int j=0; j<sz; j++) mx=max(mx, v[j].second.first), t[i][v[j].second.second]=mx; } for (int i=0; i<m-1; i++) for (int j=0; j<sz; j++) dp[i].push_back({t[i][j], t[i][j]+(s[i+1]-s[i])*w[j]}); for (int i=0; i<m-1; i++) sort(dp[i].begin(), dp[i].end()); for (int i=0; i<m-1; i++) for (int j=1; j<sz; j++) dp[i][j].second=max(dp[i][j].second, dp[i][j-1].second); //for (int i=0; i<m-1; i++) for (int j=0; j<sz; j++) cout<<"dp "<<i<<' '<<j<<' '<<dp[i][j].first<<' '<<dp[i][j].second<<'\n'; } long long arrival_time(long long Y) { ll res=Y, p=sz-1; for (int i=0; i<m-1; i++) { while (p!=-1&&dp[i][p].first>=res) p--; res=res+(s[i+1]-s[i])*x; if (p!=-1) res=max(res, dp[i][p].second); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...